@dendavidov/eslint-config-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +38 -0
- package/package.json +44 -0
- package/src/index.js +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright © 2023 Denis Davydov <mail@dendavidov.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @dendavidov/eslint-config-react
|
|
2
|
+
|
|
3
|
+
Opinionated eslint-config for React.js SPA.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -D @dendavidov/eslint-config-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Add .eslintrc.json in the root of your project
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"extends": "@dendavidov/eslint-config-react"
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
Add script to package.json -> scripts:
|
|
20
|
+
```
|
|
21
|
+
{
|
|
22
|
+
...
|
|
23
|
+
"scripts": {
|
|
24
|
+
...
|
|
25
|
+
"lint": "eslint './src/**/*.{ts,tsx}'"
|
|
26
|
+
},
|
|
27
|
+
...
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Pull requests are welcome. For major changes, please open an issue first
|
|
34
|
+
to discuss what you would like to change.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
[MIT](https://dendavidov.mit-license.org/)
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dendavidov/eslint-config-react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "eslint config",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest --watchAll=false",
|
|
9
|
+
"release": "npx semantic-release"
|
|
10
|
+
},
|
|
11
|
+
"author": "Denis Davydov mail@dendavidov.com",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git@github.com:dendavidov/eslint-config-react.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/dendavidov/eslint-config-react/issues"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"registry": "https://registry.npmjs.org/",
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.md",
|
|
26
|
+
"src/index.js"
|
|
27
|
+
],
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@semantic-release/git": "^10.0.1",
|
|
30
|
+
"jest": "^29.4.3",
|
|
31
|
+
"prettier": "^2.8.4"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.52.0",
|
|
35
|
+
"@typescript-eslint/parser": "^5.52.0",
|
|
36
|
+
"eslint": "^8.34.0",
|
|
37
|
+
"eslint-config-prettier": "^8.6.0",
|
|
38
|
+
"eslint-plugin-import": "^2.27.5",
|
|
39
|
+
"eslint-plugin-jest": "^27.2.1",
|
|
40
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
41
|
+
"eslint-plugin-react": "^7.32.2",
|
|
42
|
+
"eslint-plugin-testing-library": "^5.10.2"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
// By extending from a plugin config, we can get recommended rules without having to add them manually.
|
|
4
|
+
'eslint:recommended',
|
|
5
|
+
'plugin:react/recommended',
|
|
6
|
+
'plugin:import/recommended',
|
|
7
|
+
'plugin:jsx-a11y/recommended',
|
|
8
|
+
'plugin:@typescript-eslint/recommended',
|
|
9
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
10
|
+
'plugin:@typescript-eslint/strict',
|
|
11
|
+
// This disables the formatting rules in ESLint that Prettier is going to be responsible for handling.
|
|
12
|
+
// Make sure it's always the last config, so it gets the chance to override other configs.
|
|
13
|
+
'eslint-config-prettier',
|
|
14
|
+
],
|
|
15
|
+
"parserOptions": {
|
|
16
|
+
"project": "./tsconfig.json",
|
|
17
|
+
"ecmaVersion": 12,
|
|
18
|
+
"sourceType": "module"
|
|
19
|
+
},
|
|
20
|
+
plugins: ['jest', 'testing-library', '@typescript-eslint'],
|
|
21
|
+
settings: {
|
|
22
|
+
react: {
|
|
23
|
+
// Tells eslint-plugin-react to automatically detect the version of React to use.
|
|
24
|
+
version: 'detect',
|
|
25
|
+
},
|
|
26
|
+
// Tells eslint how to resolve imports
|
|
27
|
+
'import/resolver': {
|
|
28
|
+
node: {
|
|
29
|
+
paths: ['src'],
|
|
30
|
+
extensions: ['.ts', '.tsx'],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
overrides: [
|
|
35
|
+
{
|
|
36
|
+
files: ['**/__tests__/**/*', '**/*.{spec,test}.*'],
|
|
37
|
+
env: {
|
|
38
|
+
'jest/globals': true,
|
|
39
|
+
},
|
|
40
|
+
// A subset of the recommended rules:
|
|
41
|
+
rules: {
|
|
42
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
43
|
+
'jest/no-conditional-expect': 'error',
|
|
44
|
+
'jest/no-identical-title': 'error',
|
|
45
|
+
'jest/no-interpolation-in-snapshots': 'error',
|
|
46
|
+
'jest/no-jasmine-globals': 'error',
|
|
47
|
+
'jest/no-mocks-import': 'error',
|
|
48
|
+
'jest/valid-describe-callback': 'error',
|
|
49
|
+
'jest/valid-expect': 'error',
|
|
50
|
+
'jest/valid-expect-in-promise': 'error',
|
|
51
|
+
'jest/valid-title': 'warn',
|
|
52
|
+
|
|
53
|
+
// https://github.com/testing-library/eslint-plugin-testing-library
|
|
54
|
+
'testing-library/await-async-query': 'error',
|
|
55
|
+
'testing-library/await-async-utils': 'error',
|
|
56
|
+
'testing-library/no-await-sync-query': 'warn',
|
|
57
|
+
'testing-library/no-dom-import': ['error', 'react'],
|
|
58
|
+
'testing-library/no-wait-for-empty-callback': 'error',
|
|
59
|
+
'testing-library/no-wait-for-snapshot': 'error',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
rules: {
|
|
64
|
+
'react/react-in-jsx-scope': 'off',
|
|
65
|
+
'import/no-unresolved': [2, { ignore: ['react-dom/client'] }],
|
|
66
|
+
},
|
|
67
|
+
};
|