-
Notifications
You must be signed in to change notification settings - Fork 0
feat(eslint-config): add node and jest support #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| module.exports = { | ||
| extends: [ | ||
| './index.js', | ||
| ], | ||
| parser: 'babel-eslint', | ||
| env: { | ||
| browser: true, | ||
| }, | ||
| rules: { | ||
| 'no-console': ['error', { allow: ['warn', 'error'] }], | ||
|
|
||
| // common ones | ||
| // biblio | ||
| semi: ['error', 'never'], | ||
| quotes: [ | ||
| 'error', | ||
| 'single', | ||
| { avoidEscape: true, allowTemplateLiterals: true }, | ||
| ], | ||
|
|
||
| // wf | ||
| 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
|
|
||
| // ydr | ||
|
|
||
| // bib-service-projects | ||
| 'require-atomic-updates': 'warn', | ||
| }, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,38 @@ | ||
| const prettierConfig = require('@lovetoknow/prettier-config') | ||
|
|
||
| module.exports = { | ||
| extends: ['eslint:recommended', 'plugin:prettier/recommended'], | ||
| parser: 'babel-eslint', | ||
| parserOptions: { | ||
| ecmaVersion: 2018, | ||
| }, | ||
| env: { | ||
| es6: true, | ||
| }, | ||
| rules: { | ||
| 'no-console': ['error', { allow: ['warn', 'error'] }], | ||
|
|
||
| // Best Practices | ||
| curly: 'error', | ||
| eqeqeq: 'error', | ||
|
|
||
| // Stylistic (although Prettier will handle most of it) | ||
| 'brace-style': ['error', '1tbs', { allowSingleLine: true }], | ||
| 'one-var': ['error', 'never'], | ||
| 'linebreak-style': ['error', 'unix'], | ||
|
|
||
| // ES6 | ||
| 'no-duplicate-imports': 'error', | ||
| 'no-useless-constructor': 'error', | ||
| 'prefer-template': 'error', | ||
|
|
||
| // common ones | ||
| // biblio | ||
| semi: ['error', 'never'], | ||
| quotes: [ | ||
| 'error', | ||
| 'single', | ||
| { avoidEscape: true, allowTemplateLiterals: true }, | ||
| ], | ||
|
|
||
| // wf | ||
| 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
|
|
||
| // ydr | ||
|
|
||
| // bib-service-projects | ||
| 'require-atomic-updates': 'warn', | ||
|
|
||
| // ... more? | ||
|
|
||
| // Prettier config | ||
| 'prettier/prettier': [ | ||
| 'error', | ||
| { | ||
| ...prettierConfig, | ||
| }, | ||
| extends: [ | ||
| 'eslint:recommended', | ||
| 'plugin:prettier/recommended', | ||
| './jest.js', | ||
| ], | ||
| }, | ||
| env: { | ||
| es6: true, | ||
| }, | ||
| parserOptions: { | ||
| ecmaVersion: 2018, | ||
| }, | ||
| rules: { | ||
| // Best Practices | ||
| curly: 'error', | ||
| eqeqeq: 'error', | ||
|
|
||
| // Stylistic (although Prettier will handle most of it) | ||
| 'brace-style': ['error', '1tbs', { allowSingleLine: true }], | ||
| 'one-var': ['error', 'never'], | ||
| 'linebreak-style': ['error', 'unix'], | ||
|
|
||
| // ES6 | ||
| 'no-duplicate-imports': 'error', | ||
| 'no-useless-constructor': 'error', | ||
| 'prefer-template': 'error', | ||
|
|
||
| // Prettier config | ||
| 'prettier/prettier': [ | ||
| 'error', | ||
| { | ||
| ...prettierConfig, | ||
| }, | ||
| ], | ||
| }, | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module.exports = { | ||
| overrides: [ | ||
| { | ||
| files: ['*.spec.js', '*.test.js'], | ||
| env: { | ||
| jest: true, | ||
| }, | ||
| extends: ['plugin:jest/recommended'], | ||
| plugins: ['jest'], | ||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This requires us to have the |
||
| }, | ||
| ], | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| module.exports = { | ||
| extends: [ | ||
| './index.js', | ||
| 'plugin:node/recommended', | ||
| ], | ||
| plugins: ['node'], | ||
|
Comment on lines
+4
to
+6
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here with https://www.npmjs.com/package/eslint-plugin-node |
||
| env: { | ||
| node: true, | ||
| es2022: true, | ||
| }, | ||
| parserOptions: { | ||
| ecmaVersion: 2022, | ||
| }, | ||
| } | ||
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.
The fact that these were originally linked to specific projects still makes them suitable for node or jest environments, I would move them to the shared file 🙏🏽
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.
should we just remove (or have as a goal to remove eventually) anything for specific projects and have those projects just override any of the default settings they want to be diff?
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.
To be honest, I didn't include 100% of their rules. Only the ones that I considered to be best practices. And also,
semiandquotesmatch the prettier config. So we don't have issues using prettier-config and eslint-config together, which is what I'd recommend.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.
The references to different projects are left there only to indicate that we did a "merge" of all the different preferences everyone had. To highlight that it was done as democratically as possible.
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.
After reviewing it again, these rules that were in the index.js file are all good for node.js, including the extended configurations.