-
Notifications
You must be signed in to change notification settings - Fork 2
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
Release 5.0 #49
Release 5.0 #49
Changes from 27 commits
651299d
38ecf38
49853f3
24988c4
cb8ff06
d3fdf51
9241fa8
5796fe5
d206377
3652092
c643fff
fcdafaf
5816aca
805619a
3e0d8df
e418780
940630a
4f7fbd9
3b72259
727f525
4c591a9
4148618
b0676a1
510819d
84c17a2
ee36d4e
c767155
b1fc45a
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,34 @@ | ||
# CHANGELOG | ||
|
||
## 5.0.0 | ||
|
||
### Features | ||
|
||
- TypeScript support. | ||
- Remove peer dependencies in favour of actual dependencies. | ||
- Add automatic version detection for React. | ||
- Allow more recent versions of dependencies. | ||
- Warn about [confusing browser globals](https://www.npmjs.com/package/confusing-browser-globals) when accessing them without `window`. | ||
- Sort desctructured keys when using the React config (useful for destructured props to match the prop type definition). | ||
- Add useful rules from [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn): `unicorn/explicit-length-check`, `unicorn/import-index`, `unicorn/no-abusive-eslint-disable` | ||
- Imports are alphabetized (within individual groups: dependencies, internal, local, etc.). | ||
- Validate that array methods like `map` and `filter` return something. | ||
- Improve React component method sorting if you're using classes. | ||
- Add `react/button-has-type`. | ||
|
||
### Fixes | ||
|
||
- Removed `no-lonely-if` since there are valid cases for this pattern. | ||
- Keep `trailingComma: 'none'` for newer prettier versions. | ||
- Keep auto fix behaviour of `react-hooks/exhaustive-deps` in more recent versions. | ||
- Replace `jsx-a11y/label-has-for` with `jsx-a11y/label-has-associated-control`. | ||
- Allow for/of statements as there are valid use cases. | ||
|
||
### Breaking changes | ||
|
||
- The base JavaScript config `molindo` has been renamed to `molindo/javascript`. | ||
- The base JavaScript config is no longer included in the React config. Use `"extends": ["molindo/javascript", "molindo/react"]` to use both. | ||
- Require a minimum version of Node.js 10. | ||
- Use `eslint@^7.0.0`. | ||
- A declaration style is now enforced for functions. Since there's no auto fix, it's probably the best option to override this rule in existing code bases which use a different style extensively. | ||
- This config now installs the relevant plugins automatically. However you have to use the JavaScript version of the ESLint config (`.eslintrc.js`) and add `require('eslint-config-molindo/setupPlugins')` there. Alternatively you can still install all necessary plugins yourself. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const javascript = require('../javascript'); | ||
|
||
it('exports a valid config', () => { | ||
expect(javascript).toBeTruthy(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const typescript = require('../typescript'); | ||
|
||
it('exports a valid config', () => { | ||
expect(typescript).toBeTruthy(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"name": "eslint-config-molindo", | ||
"version": "4.0.2", | ||
"version": "5.0.0", | ||
"description": "Molindo ESLint config that implements our styleguide and helps to catch errors.", | ||
"main": "index.js", | ||
"repository": "https://github.com/molindo/eslint-config-molindo", | ||
"author": "Jan Amann <jam@molindo.at>", | ||
"license": "MIT", | ||
|
@@ -16,27 +15,38 @@ | |
"prepublish": "npm run lint && npm run test" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"setupPlugins.js", | ||
"javascript.js", | ||
"typescript.js", | ||
"config.js", | ||
"react.js" | ||
"react.js", | ||
"tsconfig.json" | ||
], | ||
"devDependencies": { | ||
"babel-eslint": "10.0.1", | ||
"eslint": "5.12.0", | ||
"eslint-plugin-import": "2.14.0", | ||
"eslint-plugin-prettier": "3.0.1", | ||
"jest": "23.6.0", | ||
"prettier": "1.15.3" | ||
"eslint": "7.4.0", | ||
"jest": "26.1.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.0.0" | ||
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. I'm really glad that all the peer dependencies are now gone. |
||
}, | ||
"dependencies": { | ||
"@rushstack/eslint-patch": "1.0.2", | ||
"@typescript-eslint/eslint-plugin": "^3.6.0", | ||
"@typescript-eslint/parser": "^3.0.0", | ||
"babel-eslint": "^10.0.0", | ||
"eslint": "^5.12.0 || ^6.0.0", | ||
"confusing-browser-globals": "^1.0.0", | ||
"eslint-plugin-css-modules": "^2.11.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-jsx-a11y": "^6.1.2", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"eslint-plugin-react": "^7.12.3", | ||
"eslint-plugin-react-hooks": "^1.6.1", | ||
"prettier": "^1.15.3" | ||
"eslint-plugin-import": "^2.22.0", | ||
"eslint-plugin-jsx-a11y": "^6.3.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-react": "^7.20.3", | ||
"eslint-plugin-react-hooks": "^4.0.6", | ||
"eslint-plugin-sort-destructure-keys": "^1.3.5", | ||
"eslint-plugin-unicorn": "^20.1.0", | ||
"prettier": "^2.0.0", | ||
"typescript": "^3.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=10" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,46 @@ | ||
const config = require('./config'); | ||
const base = require('./index'); | ||
|
||
const ERROR = 'error'; | ||
const OFF = 'off'; | ||
|
||
module.exports = Object.assign({}, base, { | ||
plugins: base.plugins.concat( | ||
module.exports = { | ||
plugins: [ | ||
'css-modules', | ||
'jsx-a11y', | ||
'react', | ||
'react-hooks' | ||
), | ||
'react-hooks', | ||
'sort-destructure-keys' | ||
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 was the last missing piece so that everything related to React props is sorted (JSX, prop types, prop destructuring). |
||
], | ||
|
||
settings: Object.assign({}, base.settings, { | ||
settings: { | ||
react: { | ||
version: 'detect' | ||
}, | ||
'import/resolver': { | ||
node: { | ||
paths: ['node_modules', 'src'] | ||
} | ||
} | ||
}), | ||
}, | ||
|
||
extends: (base.extends || []).concat( | ||
extends: [ | ||
'plugin:css-modules/recommended', | ||
'plugin:jsx-a11y/recommended', | ||
'plugin:react/recommended' | ||
), | ||
], | ||
|
||
rules: Object.assign({}, base.rules, { | ||
'jsx-a11y/label-has-for': [ | ||
ERROR, | ||
{ | ||
required: {every: ['nesting']}, | ||
allowChildren: true | ||
} | ||
], | ||
rules: { | ||
'jsx-a11y/label-has-associated-control': ERROR, | ||
'react/button-has-type': ERROR, | ||
'react/default-props-match-prop-types': ERROR, | ||
'react-hooks/rules-of-hooks': ERROR, | ||
'react-hooks/exhaustive-deps': ERROR, | ||
'react-hooks/exhaustive-deps': [ | ||
ERROR, | ||
// Since we throw on missing deps, it's not a question of whether or not | ||
// the deps are added, but rather if you have to do it manually or | ||
// automatically. Therefore go for the automatic fix. | ||
{enableDangerousAutofixThisMayCauseInfiniteLoops: true} | ||
], | ||
'react/jsx-boolean-value': [ERROR, 'never', {always: []}], | ||
'react/jsx-curly-brace-presence': [ | ||
ERROR, | ||
|
@@ -69,7 +73,10 @@ module.exports = Object.assign({}, base, { | |
ERROR, | ||
{ | ||
order: [ | ||
'type-annotations', | ||
'static-variables', | ||
'static-methods', | ||
'instance-variables', | ||
'lifecycle', | ||
'/^on.+$/', | ||
'getters', | ||
|
@@ -81,15 +88,18 @@ module.exports = Object.assign({}, base, { | |
] | ||
} | ||
], | ||
'react/sort-prop-types': ERROR | ||
}), | ||
'react/sort-prop-types': ERROR, | ||
'sort-destructure-keys/sort-destructure-keys': ERROR | ||
}, | ||
|
||
overrides: (base.overrides || []).concat({ | ||
files: config.testFiles, | ||
rules: { | ||
'css-modules/no-unused-class': OFF, | ||
'react/prop-types': OFF, | ||
'react/display-name': OFF | ||
overrides: [ | ||
{ | ||
files: config.testFiles, | ||
rules: { | ||
'css-modules/no-unused-class': OFF, | ||
'react/prop-types': OFF, | ||
'react/display-name': OFF | ||
} | ||
} | ||
}) | ||
}); | ||
] | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This enables ESLint to use dependencies of this config | ||
// (see https://github.com/eslint/eslint/issues/3458) | ||
require('@rushstack/eslint-patch/modern-module-resolution'); | ||
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. ESLint wants to handle this itself one day, but in the meantime there are some good guys from Microsoft providing a patch. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true | ||
} | ||
} |
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 only downside here is currently this IMO: import-js/eslint-plugin-import#1378 (comment). However I think it's still better that this is taken care of automatically, than us trying to keep the imports in order manually.