-
Notifications
You must be signed in to change notification settings - Fork 7.6k
add ESLint as a default Brackets extension #11988
Conversation
@@ -12,6 +12,10 @@ | |||
"branch": "", | |||
"SHA": "" | |||
}, | |||
"dependencies": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing this as part of the build process, can the node module be directly packaged or submoduled to?
Right now, Cloning the git repo makes a working copy of brackets. This will mean that we have to do a npm install for brackets to work right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we could submodule it. Shouldn't be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, it might be a problem because ESLint has a lot of dependencies which are not present in its repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would anyway pull all the dependencies when building, so using prepackaged node modules
or submoduled with dependencies
in source would have the same effect. Maybe we could trim all the dev dependencies from eslint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not exactly sure what you mean here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ESLint
has a lot of runtime dependencies like espree
or escope
(and more). Some of those dependencies might be written in ES6 and compiled to ES5 only when published to npm - that's why submoduling doesn't make much sense here. Only thing that comes to my mind is creating a repo for installed ESLint and submoduling that, but this is quite weird. What's the problem with npm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also meant NPM, But for eslint, could remove dev/testing dependencies from package.json if the install size is too big.
It is possible to put the node_modules folder in the extension directory right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's possible to move the node_modules to the extension directory, do you want it to be committed there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we would have to ship the node modules anyway, it would be ok to put it in the extension directory. Also will avoid the NPM setups needed otherwise.
I've been using this branch today and most things seem to work as expected. However, I am using
Despite this error, |
634160c fixed it, thanks! |
var rulesDirPath; | ||
var ignorePath; | ||
|
||
if (projectRoot) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could be simplified a bit by using fs.access wrapped in a promise
configPath = projectRoot + '.eslintrc';
fs.access(configPath, function (err) {
if (err || !fs.statSync(configPath).isFile()) {
opts.rules = require('eslint/conf/eslint.json').rules;
}
});
/**/
rulesDirPath = projectRoot + '.eslintrules';
fs.access(rulesDirPath, function (err) {
if (!err && fs.statSync(rulesDirPath).isDirectory()) {
opts.rulePaths = [rulesDirPath];
}
});
/**/
ignorePath = projectRoot + '.eslintignore';
fs.access(ignorePath, function (err) {
if (!err && fs.statSync(ignorePath).isFile()) {
opts.ignore = true;
opts.ignorePath = ignorePath;
}
});
This way there's no need for noop
either. The fs.accessSync
can be passed an optional mode value too if one just wants to make sure that the file exists and is readable (the default is "file is visible", basically "file exists")
fs.accessSync("foo", fs.F_OK, function (err) {/*...*/});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node in brackets is 0.10, no fs.access
there: https://nodejs.org/docs/latest-v0.10.x/api/fs.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw you're using accessSync
and a callback function? weird pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zaggino Figures, I remembered that Brackets was running on 0.12. My bad 🐹
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zaggino hah, wow, I wrote the thing in as async with a promise, noticed that it probably should be sync instead and then I don't know what happened. Waaaay too little coffee for morning coding. ☕
ESLint supports multiple ways to define en Style nit: I guess it should indented by 4 spaces. |
8020bd8
to
d1ed8d8
Compare
@ficristo made a fix in 7917a2d to consider all config file names @ficristo fixed indentation to 4 spaces in d9faa73 @abose against my better judgement, committed the actual ESLint into the extension folder so let me guys know if you have any more issues with this |
btw let me say again, we should really use
|
7917a2d
to
7ddec93
Compare
had to remove ESLint's code because of the issue above with long file names ... we should just use |
added this with npm3, no longer have the long file path problem ... |
As shown by travis grunt eslint doesn't pass. |
grunt eslint doesn't pass because this pr turns on indentation checks for 4 spaces and there're files outside of this PR not respecting this |
But the NPM install would also pull the same amount of code right. So if brackets have to be working, the node modules anyways need to be in place. |
Yes, that's true. Installer size would definitely grow. |
I don't see the point of the It shouldn't matter much but maybe use It is safe this |
|
I don't know if happened with JSLint too, but if I create a new project without a |
This died due to lack of feedback. |
ref: #11984
mostly cut out from my extension https://github.com/zaggino/brackets-eslint