@pplancq/eslint-config 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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ## @pplancq/eslint-config 1.0.0 (2024-02-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * **eslint-config:** add base rule for react with jsx-a11y ans testing-library for test ([c70823a](https://github.com/pplancq/dev-tools/commit/c70823a1b457612f744df055d67ef690531c43f9))
7
+ * **eslint-config:** add eslint base config for js ([aca46cb](https://github.com/pplancq/dev-tools/commit/aca46cb451343a76a08d3e34d299f7caff75d004))
8
+ * **eslint-config:** add eslint base config for ts ([22846cb](https://github.com/pplancq/dev-tools/commit/22846cbd2178304f31e80ae3677b727091f390db))
9
+ * **eslint-config:** add plugin prettier rule ([2c2d3a0](https://github.com/pplancq/dev-tools/commit/2c2d3a02a12a128b805b24a19eea47377c006727))
10
+ * **eslint-config:** add rule for jest and vitest ([714f323](https://github.com/pplancq/dev-tools/commit/714f323161ab9b7a982207506064fe3a2a676748))
11
+ * **eslint-config:** add script for init eslint config ([56ccc72](https://github.com/pplancq/dev-tools/commit/56ccc72f9f0388aa786e5e92b78d16ee4b1b6279))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present pplancq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @pplancq/eslint-config
2
+
3
+ This package provides pplancq eslint as an extensible shared config.
4
+
5
+ ## Usage
6
+
7
+ We export three eslint configurations for your usage.
8
+
9
+ ## Install
10
+
11
+ ```shell
12
+ npm install --save-dev @pplancq/eslint-config
13
+ ```
14
+
15
+ ## eslint config
16
+
17
+ Use with command to enable the default configuration.
18
+
19
+ ```shell
20
+ npx init-eslint-config
21
+ ```
22
+
23
+ ### @pplancq/eslint-config/react
24
+
25
+ To use, add `"eslintConfig": { "extends": ["@pplancq/eslint-config/react"] }` to your `package.json`.\
26
+ This configuration enables the rules of base, typescript, prettier, react and testing-library files.
27
+
28
+ ### @pplancq/eslint-config/node
29
+
30
+ To use, add `"eslintConfig": { "extends": ["@pplancq/eslint-config/node"] }` to your `package.json`.\
31
+ This configuration enables the rules of base, typescript and prettier files.
32
+
33
+ ### @pplancq/eslint-config/vitest
34
+
35
+ To use, add `"eslintConfig": { "extends": ["@pplancq/eslint-config/vitest"] }` to your `package.json`.\
36
+ This configuration enables the rules of vitest file.
37
+
38
+ ### @pplancq/eslint-config/jest
39
+
40
+ To use, add `"eslintConfig": { "extends": ["@pplancq/eslint-config/jest"] }` to your `package.json`.\
41
+ This configuration enables the rules of jest file.
package/bin/init.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ const { writeFileSync } = require('fs');
3
+
4
+ console.info('Add eslint config in .eslintrc.js');
5
+
6
+ writeFileSync(
7
+ '.eslintrc.js',
8
+ "module.exports = { extends: ['@pplancq/eslint-config/react', '@pplancq/eslint-config/vitest'] };\n",
9
+ {
10
+ encoding: 'utf-8',
11
+ },
12
+ );
package/jest.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['./rules/jest.js'].map(require.resolve),
3
+ };
package/node.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['./rules/base.js', './rules/typescript.js', './rules/prettier.js'].map(require.resolve),
3
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@pplancq/eslint-config",
3
+ "version": "1.0.0",
4
+ "license": "MIT",
5
+ "description": "pplancq eslint config",
6
+ "author": "pplancq <paul.plancq@outlook.fr>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/pplancq/dev-tools",
10
+ "directory": "packages/eslint-config"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/pplancq/dev-tools/issues"
14
+ },
15
+ "exports": {
16
+ "./node": "./node.js",
17
+ "./react": "./react.js",
18
+ "./jest": "./jest.js",
19
+ "./vitest": "./vitest.js"
20
+ },
21
+ "bin": {
22
+ "init-eslint-config": "./bin/init.js"
23
+ },
24
+ "keywords": [
25
+ "eslint",
26
+ "config"
27
+ ],
28
+ "dependencies": {
29
+ "@typescript-eslint/eslint-plugin": "^6.14.0",
30
+ "@typescript-eslint/parser": "^6.14.0",
31
+ "eslint-config-airbnb": "^19.0.4",
32
+ "eslint-config-prettier": "^9.1.0",
33
+ "eslint-import-resolver-typescript": "^3.6.1",
34
+ "eslint-plugin-import": "^2.29.0",
35
+ "eslint-plugin-jest": "^27.6.0",
36
+ "eslint-plugin-jest-dom": "^5.1.0",
37
+ "eslint-plugin-jest-extended": "^2.0.0",
38
+ "eslint-plugin-jsx-a11y": "^6.8.0",
39
+ "eslint-plugin-prettier": "^5.0.1",
40
+ "eslint-plugin-react": "^7.33.2",
41
+ "eslint-plugin-react-hooks": "^4.6.0",
42
+ "eslint-plugin-testing-library": "^6.2.0",
43
+ "eslint-plugin-vitest": "^0.3.17",
44
+ "eslint-plugin-vitest-globals": "^1.4.0"
45
+ },
46
+ "peerDependencies": {
47
+ "prettier": "^3.1.1",
48
+ "eslint": "^8.55.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "prettier": {
52
+ "optional": true
53
+ }
54
+ },
55
+ "volta": {
56
+ "node": "20.10.0",
57
+ "npm": "10.2.5"
58
+ }
59
+ }
package/react.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['./rules/react.js', './rules/prettier.js'].map(require.resolve),
3
+ };
package/rules/base.js ADDED
@@ -0,0 +1,37 @@
1
+ module.exports = {
2
+ extends: ['airbnb/base'],
3
+ plugins: ['import'],
4
+ parserOptions: {
5
+ ecmaVersion: 'latest',
6
+ },
7
+ env: {
8
+ browser: true,
9
+ node: true,
10
+ },
11
+ rules: {
12
+ // eslint
13
+ 'no-console': [
14
+ 'error',
15
+ {
16
+ allow: ['info', 'warn', 'error'],
17
+ },
18
+ ],
19
+ 'no-plusplus': [
20
+ 'error',
21
+ {
22
+ allowForLoopAfterthoughts: true,
23
+ },
24
+ ],
25
+
26
+ // eslint-plugin-import https://github.com/import-js/eslint-plugin-import
27
+ 'import/prefer-default-export': 'off',
28
+ 'import/no-default-export': 'error',
29
+ },
30
+ settings: {
31
+ 'import/resolver': {
32
+ node: {
33
+ extensions: ['.js'],
34
+ },
35
+ },
36
+ },
37
+ };
package/rules/jest.js ADDED
@@ -0,0 +1,37 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ['*.{test,spec}.{js,jsx,ts,tsx}'],
5
+ plugins: ['jest', 'jest-extended'],
6
+ env: {
7
+ 'jest/globals': true,
8
+ },
9
+ rules: {
10
+ 'import/no-extraneous-dependencies': 'off',
11
+
12
+ // eslint-plugin-jest https://github.com/jest-community/eslint-plugin-jest
13
+ 'jest/no-conditional-expect': 'error',
14
+ 'jest/no-identical-title': 'error',
15
+ 'jest/no-interpolation-in-snapshots': 'error',
16
+ 'jest/no-jasmine-globals': 'error',
17
+ 'jest/no-mocks-import': 'error',
18
+ 'jest/valid-describe-callback': 'error',
19
+ 'jest/valid-expect': 'error',
20
+ 'jest/valid-expect-in-promise': 'error',
21
+ 'jest/valid-title': 'error',
22
+ 'jest/prefer-called-with': 'error',
23
+ 'jest/prefer-hooks-on-top': 'error',
24
+ 'jest/prefer-strict-equal': 'error',
25
+ 'jest/prefer-to-contain': 'error',
26
+ 'jest/prefer-to-have-length': 'error',
27
+
28
+ // eslint-plugin-jest-extended https://github.com/jest-community/eslint-plugin-jest-extended
29
+ 'jest-extended/prefer-to-be-array': 'error',
30
+ 'jest-extended/prefer-to-be-false': 'error',
31
+ 'jest-extended/prefer-to-be-object': 'error',
32
+ 'jest-extended/prefer-to-be-true': 'error',
33
+ 'jest-extended/prefer-to-have-been-called-once': 'error',
34
+ },
35
+ },
36
+ ],
37
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['plugin:prettier/recommended'],
3
+ };
package/rules/react.js ADDED
@@ -0,0 +1,117 @@
1
+ module.exports = {
2
+ extends: [
3
+ 'airbnb',
4
+ 'airbnb/hooks',
5
+ 'plugin:react/recommended',
6
+ 'plugin:react/jsx-runtime',
7
+ './base.js',
8
+ './typescript.js',
9
+ ],
10
+ rules: {
11
+ // eslint-plugin-import https://github.com/import-js/eslint-plugin-import
12
+ 'import/extensions': [
13
+ 'error',
14
+ 'ignorePackages',
15
+ {
16
+ js: 'never',
17
+ jsx: 'never',
18
+ },
19
+ ],
20
+
21
+ // eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
22
+ 'react/no-multi-comp': [
23
+ 'error',
24
+ {
25
+ ignoreStateless: false,
26
+ },
27
+ ],
28
+ 'react/jsx-props-no-spreading': 'off',
29
+ 'react/no-unescaped-entities': 'off',
30
+ 'react/jsx-filename-extension': [
31
+ 'error',
32
+ {
33
+ extensions: ['.jsx'],
34
+ },
35
+ ],
36
+ 'react/function-component-definition': [
37
+ 'error',
38
+ {
39
+ namedComponents: ['function-declaration', 'arrow-function', 'function-expression'],
40
+ unnamedComponents: ['arrow-function', 'function-expression'],
41
+ },
42
+ ],
43
+
44
+ // eslint-plugin-react-hooks https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hook
45
+ 'react-hooks/exhaustive-deps': 'warn',
46
+ },
47
+ settings: {
48
+ react: {
49
+ version: 'detect',
50
+ },
51
+ 'import/resolver': {
52
+ node: {
53
+ extensions: ['.js', '.jsx'],
54
+ },
55
+ },
56
+ },
57
+ overrides: [
58
+ {
59
+ files: ['**/*.ts?(x)'],
60
+ settings: {
61
+ 'import/resolver': {
62
+ node: {
63
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
64
+ },
65
+ },
66
+ },
67
+ rules: {
68
+ // eslint-plugin-import https://github.com/import-js/eslint-plugin-import
69
+ 'import/extensions': [
70
+ 'error',
71
+ 'ignorePackages',
72
+ {
73
+ js: 'never',
74
+ jsx: 'never',
75
+ ts: 'never',
76
+ tsx: 'never',
77
+ },
78
+ ],
79
+
80
+ // eslint-plugin-react https://github.com/jsx-eslint/eslint-plugin-react
81
+ 'react/require-default-props': 'off',
82
+ 'react/jsx-filename-extension': [
83
+ 'error',
84
+ {
85
+ extensions: ['.jsx', '.tsx'],
86
+ },
87
+ ],
88
+ },
89
+ },
90
+ {
91
+ extends: ['plugin:jest-dom/recommended'],
92
+ files: ['*.{test,spec}.{js,jsx,ts,tsx}'],
93
+ plugins: ['testing-library'],
94
+ rules: {
95
+ // eslint-plugin-testing-library https://github.com/testing-library/eslint-plugin-testing-library
96
+ 'testing-library/await-async-queries': 'error',
97
+ 'testing-library/await-async-utils': 'error',
98
+ 'testing-library/no-await-sync-queries': 'error',
99
+ 'testing-library/no-container': 'error',
100
+ 'testing-library/no-debugging-utils': 'error',
101
+ 'testing-library/no-dom-import': ['error', 'react'],
102
+ 'testing-library/no-node-access': 'error',
103
+ 'testing-library/no-promise-in-fire-event': 'error',
104
+ 'testing-library/no-render-in-lifecycle': 'error',
105
+ 'testing-library/no-unnecessary-act': 'error',
106
+ 'testing-library/no-wait-for-multiple-assertions': 'error',
107
+ 'testing-library/no-wait-for-side-effects': 'error',
108
+ 'testing-library/no-wait-for-snapshot': 'error',
109
+ 'testing-library/prefer-find-by': 'error',
110
+ 'testing-library/prefer-presence-queries': 'error',
111
+ 'testing-library/prefer-query-by-disappearance': 'error',
112
+ 'testing-library/prefer-screen-queries': 'error',
113
+ 'testing-library/render-result-naming-convention': 'error',
114
+ },
115
+ },
116
+ ],
117
+ };
@@ -0,0 +1,43 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ['**/*.ts?(x)'],
5
+ extends: ['plugin:@typescript-eslint/recommended'],
6
+ parser: '@typescript-eslint/parser',
7
+ settings: {
8
+ 'import/resolver': {
9
+ typescript: true,
10
+ node: {
11
+ extensions: ['.js', '.ts'],
12
+ },
13
+ },
14
+ },
15
+ rules: {
16
+ // typescript-eslint/typescript-eslint https://github.com/typescript-eslint/typescript-eslint
17
+ // Add TypeScript specific rules (and turn off ESLint equivalents)
18
+ 'no-shadow': 'off',
19
+ '@typescript-eslint/no-shadow': 'error',
20
+ 'no-unused-expressions': 'off',
21
+ '@typescript-eslint/no-unused-expressions': 'error',
22
+ 'no-use-before-define': 'off',
23
+ '@typescript-eslint/no-use-before-define': 'error',
24
+ 'no-redeclare': 'off',
25
+ '@typescript-eslint/no-redeclare': 'error',
26
+ 'no-useless-constructor': 'off',
27
+ '@typescript-eslint/no-useless-constructor': 'error',
28
+
29
+ '@typescript-eslint/consistent-type-assertions': 'warn',
30
+
31
+ // eslint-plugin-import https://github.com/import-js/eslint-plugin-import
32
+ 'import/extensions': [
33
+ 'error',
34
+ 'ignorePackages',
35
+ {
36
+ js: 'never',
37
+ ts: 'never',
38
+ },
39
+ ],
40
+ },
41
+ },
42
+ ],
43
+ };
@@ -0,0 +1,30 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ['*.{test,spec}.{js,jsx,ts,tsx}'],
5
+ plugins: ['vitest', 'vitest-globals'],
6
+ env: {
7
+ 'vitest-globals/env': true,
8
+ },
9
+ rules: {
10
+ 'import/no-extraneous-dependencies': 'off',
11
+
12
+ // eslint-plugin-vitest https://github.com/veritem/eslint-plugin-vitest
13
+ 'vitest/no-conditional-expect': 'error',
14
+ 'vitest/no-identical-title': 'error',
15
+ 'vitest/no-interpolation-in-snapshots': 'error',
16
+ 'vitest/no-mocks-import': 'error',
17
+ 'vitest/valid-describe-callback': 'error',
18
+ 'vitest/valid-expect': 'error',
19
+ 'vitest/valid-title': 'warn',
20
+ 'vitest/prefer-called-with': 'error',
21
+ 'vitest/prefer-strict-equal': 'error',
22
+ 'vitest/prefer-to-contain': 'error',
23
+ 'vitest/prefer-to-have-length': 'error',
24
+ 'vitest/prefer-to-be-truthy': 'error',
25
+ 'vitest/prefer-to-be-falsy': 'error',
26
+ 'vitest/prefer-to-be-object': 'error',
27
+ },
28
+ },
29
+ ],
30
+ };
package/vitest.js ADDED
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['./rules/vitest.js'].map(require.resolve),
3
+ };