-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLint #1483
ESLint #1483
Conversation
Yes, that would be great! |
Resolved merge conflict
Hmmm. It seems like Any idea on how to fix this? |
Simplified build mechanism New lint rules Ignore components.js
If eslint itself is compatible with Node 4, we could just put it in |
ESLint dropped supporting Node.js 4 in April. |
Removed quotes around `pattern` and `alias`
Definitely, yes. Also, there is the issue that (because I used the VSCode auto formatter) all pairs of 4 spaces are converted into one tab, breaking the tabs for indent and spaces for alignment rule. |
Hey @RunDevelopment, thanks for submitting this!
Yes, this needs serious review by all of us. I see a ton of changes (229 files changed?!). I would prefer to pave the cowpaths and pick rules that are actually mostly enforced already, than to make such extensive changes to the codebase. I also disagree with several of these rules. Many seem to be applying an arbitrary code style that neither matches the project, nor has any objective reasoning (e.g. enforce quotes in object keys?! Why?!). Also, our indentation is not tabs, it's smart tabs, i.e. tabs for indentation and spaces for alignment. I'm also opposed to overlinting, as it tends to get in the way. Let's start with a small set that we mostly follow already, and expand as needed. I suggested what I consider a good starting point above, but did not see a response. Is there a reason you feel we need more rules? Do you disagree with any of the rules there? Comments would also be useful for reviewing this, both now and in the future, so that people don't have to look up every single cryptic ESLint code to understand what's going on. I also disagree with using errors for this. Anything related to linting should just be a warning. An error is something that would actually break code, not code style! |
Well, almost every language definition, plugin and most of the minified files thanks to
I don't think that that is possible. Many language definitions have vastly different from e.g.
Do you mean "the names of tokens are surrounded by single quotes"?
Well, it still is
I actually used your suggestion as the starting point and went from there. Some rules I had to change (
I simply consider many rules of ESLint to be very useful and think we should encourage contributors to follow best practices and avoid possible errors (by force).
I honestly did not know that this was possible with ESLint because JSON does not allow comment by default.
I made this decision with Travis CI in mind because if a build fails, the contributor will see that change is required without anyone having to tell them. This is supposed to speed up the review process as the linter will point out common mistakes like wrong indentation. |
Ok, agreed.
Ok. Thank you for being willing to do the tedious manual work.
I disagree with blanket adoption of "best practices" lists. We should evaluate each of these practices and see if we want it in our project.
Thank you. I will wait until then to review rules in more detail.
I'm generally opposed to linting by force. Linting is helpful to point out potential issues, but ultimately, most rules are rules of thumb and should not be followed in cases when they doesn't actually help readability or maintainability. Also, linting is not just utilized in Travis, but also by many editor plugins. It's very annoying if a syntax error is highlighted the same way in my editor as a stylistic error. |
You're exactly right. This is what I also intended to do.
That's true. Warning it is then for most stylistic rules. I'd still like to keep things like |
Closed in favor of #1796. |
This PR fixes the indentation errors of all language definitions.
For the vast majority of files, this doesn't do much. A space or two and an additional line at the end of the file. (I used VS Code's auto formatter.)
This also enforces the widespread convention that the names of tokens are surrounded by single quotes.
Edit:
This PR now introduces ESLint to the Prism code base with the following features:
.eslintrc.json
. This includes both stylistic rules as well as some best practices and possible errors.npx gulp lint
.lint
task is also part of thedefault
task. (This also ensures that Travis CI uses the linter.)npx gulp lint-fix
.2 new dev dependencies were added (
gulp-eslint
,gulp-if
).