-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add ESLint to the project #27
Conversation
Thank you for opening the PR and kicking it off! I'll move our discussion here as this is where the code is.
I'm ok with changing the style of this project to conform to best practices.
A big linter configuration is something I'd like to avoid. I'd prefer to keep it as simple as possible.
Projects like preact put it in package.json. Unless there is a consensus, I'd prefer
It's more of a personal preference. In general, I find the root directory is becoming a bit dumping grounds for dotfiles:
All these files detract from the core of the project (the actual code). Especially for small projects (like this one). Seeing a ton of configuration for small projects is (to me) a project smell. Linting, formatting, and configuration are all important but in small, low velocity projects a ton of customization can add more to the cognitive overhead than anything. Hence why I want to keep the number of config lines and config files to a minimum.
My interest lies entirely in minimizing the number of lines and files dedicated for a good linting configuration. I'm open to suggestions. One doesn't need to specify the individual rules when using these
I'm totally on board with defining a linting configuration and communicating style preferences and adding them to the project. However, I do have reservations with committing a bunch of dependencies to the project. I noticed that this commit adds 1,409 lines to I'm only interested in running the latest eslint (and relevant plugins dictated by the config) when one invokes
jomini can be used in both browser and node.js. As long as jomini works on node LTS, I'm fine.
If existing code is flagged, it should be fixed
Since these are not flagged by Oftentimes when I'm unsure of the best approach, I see what others are doing. Taking a look at the prolific sindresorhus, his projects more often than not don't generate a package-lock.json file and use the xo linter (built ontop of eslint). Maybe this is something that we should explore. What do you think? |
Why?
That would make
If that's the case, we can make a separate project which defines the linter rules, and extend that.
That's true.
These are dev dependencies. They don't impact production code using the library.
eslint has 7.9 million weekly downloads, and eslint-plugin-import has 4.6 million. Are you worried about security with this ammount of eyes watching it?
Technically linting is a form of testing.
Personally I like ESLint to run in the background, and highlight linting errors to me as I type (through a VSCode extension). This is like intellisense.
In that case we need to decide if we write in an old version of javascript and enforce it through linting, or we add a build step which performs transpilation (babel).
I am not familiar with
As a separate issue, transpilation & browserification can be handled by |
If given a choice of maintaining 400 lines or 1 line, I'd choose 1 line.
How would adding three lines making it a long file? 😕 This was my proposal: {
"eslintConfig": {
"extends": ["eslint:recommended", "plugin:node/recommended", "prettier"]
}
}
You are more than welcome to do that.
No it's not eslint's lockfile I'm worried about reviewing, it's jomini's lockfile.
jomini can be used without issue in browsers with a bundler.
I would like to only rely upon existing an eslint plugins that encapsulate best practices and refrain from personal preferences.
I'm not familiar with it either, but XO uses the latest version of eslint under the hood, and another synonym for staleness is stability. But maybe xo isn't a good fit and |
It's configuration. Not really something you fix bugs in.
If we keep only minimal linting (
I recall. I disagree with it.
Jomini's lockfile is a superset of eslint lockfile.
Right now it can. Changes may accidentally break that. We can enforce it via eslint.
Lynt is even worse than xo for the same reasons. 453 weekly downloads and last commit to master 11 months ago. |
If we look at eslint documentation about
Look at all the goodies |
Existing conventions that won't be enforced by
and additional rules as seen in |
Looks like jomini code is already ES3. I've changed the This has the effect of changing Looks like generated |
I went ahead and made the linter enforce ES3. Existing code is already compliant. Existing code is flagged as error by
If you look at the rules enabled by extending xo, you'll see it targets bleeding edge ES versions. That's not fit for our purpose as you want backwards compat, and so far looks like we're going with ES3. I understand we don't want to maintain transpilation / browserification as part of this project. |
I think all that's left to do at this point is to go over the rules I propose in addition to the recommended ones (eslint docs, eslint-plugin-import docs), and for each make a ruling on whether it stays in the config or gets disabled. Reminder, existing stylistic conventions that I propose and won't be enforced by
|
Looks like we're still in disagreement (which is fine!) on the best way to add eslint + configuration. So we'll table discussion until new ideas can be presented. I'm still happy to accept your code changes here if you'd like to split those off into a separate PR. |
Do I understand correctly that you intend on accepting the changes as long as |
Yeah minimal is good. I'm kinda flabbergasted that there isn't something like:
and that'd be it. (This is a bit of a rhetorical statement). Rust, go, c++, python need zero configuration to set up linting, yet JS needs configuration (if not 100's of lines of configuration)? 😕 And now I'm having second thoughts about the package-lock.json as I still can't get over how big of a change linting is. I'm thinking that maybe it's best to to set This topic is rather exhausting for a code base that measures in at a 100 lines of code 😆 When I said
I meant only the changes under |
"Best practices" are subjective, and the industry isn't exactly standardized.
Actually, you remind me that
You mean the changes made to fix linting errors? I can make it in to a separate PR if you insist but I don't see the value in it. |
This reverts commit 209c921.
Fixes lint issues introduced by nickbabcock#27
This reverts commit 8bc79d3.
because https://eslint.org/docs/rules/no-prototype-builtins Fixes lint errors introduced by nickbabcock#27
I'm happy to accept PRs that updates code to conform to some eslint rule, but as of now I have yet to see a solution that minimizes the amount of cruft that is added to the project. Any solution would need to be less than a half dozen lines. |
This adds an ESLint configuration per #24
The rules (incl. style) are derived from the existing practices in the project.
Simple inconsistencies have been fixed in a separate commit in this pull request.
Running the linter (
npm run lint
) results in empty output.