@scaleway/eslint-config-react 4.0.9 → 5.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.
@@ -0,0 +1,192 @@
1
+ import { fixupConfigRules, fixupPluginRules } from '@eslint/compat'
2
+ import { FlatCompat } from '@eslint/eslintrc'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const filename = fileURLToPath(import.meta.url)
7
+ const dirname = path.dirname(filename)
8
+
9
+ const compat = new FlatCompat({
10
+ baseDirectory: dirname,
11
+ })
12
+
13
+ const config = compat.extends('airbnb-base')
14
+
15
+ const defaultAirBnbRules = [...fixupPluginRules(config)].reduce(
16
+ (acc, currentConfig) => ({
17
+ ...acc,
18
+ ...currentConfig.rules,
19
+ }),
20
+ {},
21
+ )
22
+
23
+ export default [
24
+ ...fixupConfigRules(compat.extends('airbnb-base')),
25
+ {
26
+ rules: {
27
+ // Replace Airbnb 'camelcase' rule with '@typescript-eslint/naming-convention'
28
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
29
+ camelcase: 'off',
30
+ // The `@typescript-eslint/naming-convention` rule allows `leadingUnderscore` and `trailingUnderscore` settings. However, the existing `no-underscore-dangle` rule already takes care of this.
31
+ '@typescript-eslint/naming-convention': [
32
+ 'error',
33
+ // Allow camelCase variables (23.2), PascalCase variables (23.8), and UPPER_CASE variables (23.10)
34
+ {
35
+ selector: 'variable',
36
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
37
+ },
38
+ // Allow camelCase functions (23.2), and PascalCase functions (23.8)
39
+ {
40
+ selector: 'function',
41
+ format: ['camelCase', 'PascalCase'],
42
+ },
43
+ // Airbnb recommends PascalCase for classes (23.3), and although Airbnb does not make TypeScript recommendations, we are assuming this rule would similarly apply to anything "type like", including interfaces, type aliases, and enums
44
+ {
45
+ selector: 'typeLike',
46
+ format: ['PascalCase'],
47
+ },
48
+ ],
49
+
50
+ // Replace Airbnb 'default-param-last' rule with '@typescript-eslint' version
51
+ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/default-param-last.md
52
+ 'default-param-last': 'off',
53
+ '@typescript-eslint/default-param-last':
54
+ defaultAirBnbRules['default-param-last'],
55
+
56
+ // Replace Airbnb 'dot-notation' rule with '@typescript-eslint' version
57
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/dot-notation.md
58
+ 'dot-notation': 'off',
59
+ '@typescript-eslint/dot-notation': defaultAirBnbRules['dot-notation'],
60
+
61
+ // Replace Airbnb 'no-array-constructor' rule with '@typescript-eslint' version
62
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-array-constructor.md
63
+ 'no-array-constructor': 'off',
64
+ '@typescript-eslint/no-array-constructor':
65
+ defaultAirBnbRules['no-array-constructor'],
66
+
67
+ // Replace Airbnb 'no-dupe-class-members' rule with '@typescript-eslint' version
68
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
69
+ 'no-dupe-class-members': 'off',
70
+ '@typescript-eslint/no-dupe-class-members':
71
+ defaultAirBnbRules['no-dupe-class-members'],
72
+
73
+ // Replace Airbnb 'no-empty-function' rule with '@typescript-eslint' version
74
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
75
+ 'no-empty-function': 'off',
76
+ '@typescript-eslint/no-empty-function':
77
+ defaultAirBnbRules['no-empty-function'],
78
+
79
+ // Replace Airbnb 'no-extra-parens' rule with '@typescript-eslint' version
80
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
81
+ 'no-extra-parens': 'off',
82
+ '@typescript-eslint/no-extra-parens':
83
+ defaultAirBnbRules['no-extra-parens'],
84
+
85
+ // Replace Airbnb 'no-implied-eval' and 'no-new-func' rules with '@typescript-eslint' version
86
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
87
+ 'no-implied-eval': 'off',
88
+ 'no-new-func': 'off',
89
+ '@typescript-eslint/no-implied-eval':
90
+ defaultAirBnbRules['no-implied-eval'],
91
+
92
+ // Replace Airbnb 'no-loss-of-precision' rule with '@typescript-eslint' version
93
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loss-of-precision.md
94
+ 'no-loss-of-precision': 'off',
95
+ '@typescript-eslint/no-loss-of-precision':
96
+ defaultAirBnbRules['no-loss-of-precision'],
97
+
98
+ // Replace Airbnb 'no-loop-func' rule with '@typescript-eslint' version
99
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
100
+ 'no-loop-func': 'off',
101
+ '@typescript-eslint/no-loop-func': defaultAirBnbRules['no-loop-func'],
102
+
103
+ // Replace Airbnb 'no-magic-numbers' rule with '@typescript-eslint' version
104
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
105
+ 'no-magic-numbers': 'off',
106
+ '@typescript-eslint/no-magic-numbers':
107
+ defaultAirBnbRules['no-magic-numbers'],
108
+
109
+ // Replace Airbnb 'no-redeclare' rule with '@typescript-eslint' version
110
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-redeclare.md
111
+ 'no-redeclare': 'off',
112
+ '@typescript-eslint/no-redeclare': defaultAirBnbRules['no-redeclare'],
113
+
114
+ // Replace Airbnb 'no-shadow' rule with '@typescript-eslint' version
115
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
116
+ 'no-shadow': 'off',
117
+ '@typescript-eslint/no-shadow': defaultAirBnbRules['no-shadow'],
118
+
119
+ // Replace Airbnb 'no-unused-expressions' rule with '@typescript-eslint' version
120
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
121
+ 'no-unused-expressions': 'off',
122
+ '@typescript-eslint/no-unused-expressions':
123
+ defaultAirBnbRules['no-unused-expressions'],
124
+
125
+ // Replace Airbnb 'no-unused-vars' rule with '@typescript-eslint' version
126
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
127
+ 'no-unused-vars': 'off',
128
+ '@typescript-eslint/no-unused-vars': defaultAirBnbRules['no-unused-vars'],
129
+
130
+ // Replace Airbnb 'no-use-before-define' rule with '@typescript-eslint' version
131
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
132
+ 'no-use-before-define': 'off',
133
+ '@typescript-eslint/no-use-before-define':
134
+ defaultAirBnbRules['no-use-before-define'],
135
+
136
+ // Replace Airbnb 'no-useless-constructor' rule with '@typescript-eslint' version
137
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
138
+ 'no-useless-constructor': 'off',
139
+ '@typescript-eslint/no-useless-constructor':
140
+ defaultAirBnbRules['no-useless-constructor'],
141
+
142
+ // Replace Airbnb 'quotes' rule with '@typescript-eslint' version
143
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
144
+ quotes: 'off',
145
+ // '@typescript-eslint/quotes': defaultAirBnbRules.quotes,
146
+
147
+ // Replace Airbnb 'require-await' rule with '@typescript-eslint' version
148
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-await.md
149
+ 'require-await': 'off',
150
+ '@typescript-eslint/require-await': defaultAirBnbRules['require-await'],
151
+
152
+ // Replace Airbnb 'no-return-await' rule with '@typescript-eslint' version
153
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
154
+ 'no-return-await': 'off',
155
+ '@typescript-eslint/return-await': [
156
+ defaultAirBnbRules['no-return-await'],
157
+ 'in-try-catch',
158
+ ],
159
+
160
+ // Append 'ts' and 'tsx' to Airbnb 'import/extensions' rule
161
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
162
+ 'import/extensions': [
163
+ defaultAirBnbRules['import/extensions'][0],
164
+ defaultAirBnbRules['import/extensions'][1],
165
+ {
166
+ ...defaultAirBnbRules['import/extensions'][2],
167
+ ts: 'never',
168
+ tsx: 'never',
169
+ },
170
+ ],
171
+
172
+ // Append 'ts' and 'tsx' extensions to Airbnb 'import/no-extraneous-dependencies' rule
173
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
174
+ 'import/no-extraneous-dependencies': [
175
+ defaultAirBnbRules['import/no-extraneous-dependencies'][0],
176
+ {
177
+ ...defaultAirBnbRules['import/no-extraneous-dependencies'][1],
178
+ devDependencies: defaultAirBnbRules[
179
+ 'import/no-extraneous-dependencies'
180
+ ][1].devDependencies.reduce((result, devDep) => {
181
+ const toAppend = [devDep]
182
+ const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1')
183
+ if (devDepWithTs !== devDep) {
184
+ toAppend.push(devDepWithTs)
185
+ }
186
+ return [...result, ...toAppend]
187
+ }, []),
188
+ },
189
+ ],
190
+ },
191
+ },
192
+ ]
package/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import emotion from './emotion.mjs'
2
2
  import javascript from './javascript.mjs'
3
3
  import typescript from './typescript.mjs'
4
+ import stylistic from './stylistic.mjs'
4
5
 
5
- export { emotion, javascript, typescript }
6
+ export { emotion, javascript, stylistic, typescript }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/eslint-config-react",
3
- "version": "4.0.9",
3
+ "version": "5.0.0",
4
4
  "description": "Scaleway React eslint shared config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -20,37 +20,40 @@
20
20
  "./javascript": "./javascript.mjs",
21
21
  "./typescript": "./typescript.mjs",
22
22
  "./emotion": "./emotion.mjs",
23
- "./shared": "./shared.mjs"
23
+ "./shared": "./shared.mjs",
24
+ "./stylistic": "./stylistic.mjs"
24
25
  },
25
26
  "files": [
27
+ "airbnb/*",
28
+ "emotion.mjs",
26
29
  "index.mjs",
27
30
  "javascript.mjs",
28
- "typescript.mjs",
29
31
  "shared.mjs",
30
- "emotion.mjs"
32
+ "stylistic.mjs",
33
+ "typescript.mjs"
31
34
  ],
32
35
  "license": "MIT",
33
36
  "dependencies": {
34
37
  "@emotion/eslint-plugin": "11.12.0",
35
- "@eslint/compat": "1.2.2",
36
- "@eslint/eslintrc": "3.1.0",
37
- "@typescript-eslint/eslint-plugin": "7.18.0",
38
- "@typescript-eslint/parser": "7.18.0",
38
+ "@eslint/compat": "1.2.3",
39
+ "@eslint/eslintrc": "3.2.0",
40
+ "@stylistic/eslint-plugin": "2.11.0",
41
+ "@typescript-eslint/eslint-plugin": "8.16.0",
42
+ "@typescript-eslint/parser": "8.16.0",
39
43
  "eslint-config-airbnb": "19.0.4",
40
- "eslint-config-airbnb-typescript": "18.0.0",
41
44
  "eslint-config-prettier": "9.1.0",
42
45
  "eslint-plugin-deprecation": "3.0.0",
43
46
  "eslint-plugin-eslint-comments": "3.2.0",
44
47
  "eslint-plugin-import": "2.31.0",
45
- "eslint-plugin-jsx-a11y": "6.10.1",
48
+ "eslint-plugin-jsx-a11y": "6.10.2",
46
49
  "eslint-plugin-react": "7.37.2",
47
50
  "eslint-plugin-react-hooks": "5.0.0"
48
51
  },
49
52
  "peerDependencies": {
50
- "eslint": ">= 9.7"
53
+ "eslint": ">= 9.13"
51
54
  },
52
55
  "devDependencies": {
53
56
  "eslint": "9.13.0",
54
- "typescript": "5.6.3"
57
+ "typescript": "5.7.2"
55
58
  }
56
59
  }
package/shared.mjs CHANGED
@@ -2,6 +2,7 @@ import { fixupConfigRules } from '@eslint/compat'
2
2
  import { FlatCompat } from '@eslint/eslintrc'
3
3
  import path from 'node:path'
4
4
  import { fileURLToPath } from 'node:url'
5
+ import stylisticJs from './stylistic.mjs'
5
6
 
6
7
  const filename = fileURLToPath(import.meta.url)
7
8
  const dirname = path.dirname(filename)
@@ -19,9 +20,13 @@ export default [
19
20
  'plugin:react/jsx-runtime',
20
21
  ),
21
22
  ),
23
+ ...stylisticJs,
22
24
  {
23
25
  rules: {
24
26
  curly: 'error',
27
+ 'no-use-before-define': 'off',
28
+ 'import/extensions': 'off',
29
+ 'dot-notation': 'off',
25
30
 
26
31
  'import/order': [
27
32
  'error',
package/stylistic.mjs ADDED
@@ -0,0 +1,68 @@
1
+ import { fixupPluginRules } from '@eslint/compat'
2
+ import { FlatCompat } from '@eslint/eslintrc'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+ import stylisticPlugin from '@stylistic/eslint-plugin'
6
+
7
+ const filename = fileURLToPath(import.meta.url)
8
+ const dirname = path.dirname(filename)
9
+
10
+ const compat = new FlatCompat({
11
+ baseDirectory: dirname,
12
+ })
13
+
14
+ const config = compat.extends('airbnb-base')
15
+
16
+ const defaultAirBnbRules = [...fixupPluginRules(config)].reduce(
17
+ (acc, currentConfig) => ({
18
+ ...acc,
19
+ ...currentConfig.rules,
20
+ }),
21
+ {},
22
+ )
23
+
24
+ export default [
25
+ {
26
+ plugins: {
27
+ '@stylistic': stylisticPlugin,
28
+ },
29
+ },
30
+ stylisticPlugin.configs['disable-legacy'],
31
+ stylisticPlugin.configs['recommended-flat'],
32
+ {
33
+ rules: {
34
+ '@stylistic/quotes': 'off',
35
+ '@stylistic/operator-linebreak': 'off',
36
+ '@stylistic/indent': 'off',
37
+ '@stylistic/quote-props': 'off',
38
+ '@stylistic/indent-binary-ops': 'off',
39
+ '@stylistic/arrow-parens': 'off',
40
+
41
+ '@stylistic/brace-style': defaultAirBnbRules['brace-style'],
42
+ '@stylistic/comma-dangle': [
43
+ defaultAirBnbRules['comma-dangle'][0],
44
+ {
45
+ ...defaultAirBnbRules['comma-dangle'][1],
46
+ enums: defaultAirBnbRules['comma-dangle'][1].arrays,
47
+ generics: defaultAirBnbRules['comma-dangle'][1].arrays,
48
+ tuples: defaultAirBnbRules['comma-dangle'][1].arrays,
49
+ },
50
+ ],
51
+ '@stylistic/comma-spacing': defaultAirBnbRules['comma-spacing'],
52
+ '@stylistic/func-call-spacing': defaultAirBnbRules['func-call-spacing'],
53
+ '@stylistic/keyword-spacing': defaultAirBnbRules['keyword-spacing'],
54
+ '@stylistic/no-extra-semi': defaultAirBnbRules['no-extra-semi'],
55
+ '@stylistic/object-curly-spacing':
56
+ defaultAirBnbRules['object-curly-spacing'],
57
+ semi: 'off',
58
+ '@stylistic/semi': 'off',
59
+ '@stylistic/space-before-blocks':
60
+ defaultAirBnbRules['space-before-blocks'],
61
+ '@stylistic/space-before-function-paren':
62
+ defaultAirBnbRules['space-before-function-paren'],
63
+ '@stylistic/space-infix-ops': defaultAirBnbRules['space-infix-ops'],
64
+ '@stylistic/lines-between-class-members':
65
+ defaultAirBnbRules['lines-between-class-members'],
66
+ },
67
+ },
68
+ ]
package/typescript.mjs CHANGED
@@ -4,6 +4,7 @@ import deprecation from 'eslint-plugin-deprecation'
4
4
  import path from 'node:path'
5
5
  import { fileURLToPath } from 'node:url'
6
6
  import shared from './shared.mjs'
7
+ import airbnbTypescript from './airbnb/typescript.mjs'
7
8
 
8
9
  const filename = fileURLToPath(import.meta.url)
9
10
  const dirname = path.dirname(filename)
@@ -15,12 +16,12 @@ const compat = new FlatCompat({
15
16
  export default [
16
17
  ...fixupConfigRules(
17
18
  compat.extends(
18
- 'eslint-config-airbnb',
19
- 'eslint-config-airbnb-typescript',
19
+ 'airbnb-base',
20
20
  'plugin:@typescript-eslint/recommended',
21
21
  'plugin:@typescript-eslint/recommended-requiring-type-checking',
22
22
  ),
23
23
  ),
24
+ ...airbnbTypescript,
24
25
  ...shared,
25
26
  {
26
27
  plugins: {
@@ -47,7 +48,6 @@ export default [
47
48
  '@typescript-eslint/prefer-string-starts-ends-with': 'error',
48
49
  '@typescript-eslint/prefer-ts-expect-error': 'error',
49
50
  '@typescript-eslint/no-floating-promises': 'error',
50
-
51
51
  '@typescript-eslint/no-misused-promises': [
52
52
  'error',
53
53
  {
@@ -72,6 +72,33 @@ export default [
72
72
  allowExpressions: true,
73
73
  },
74
74
  ],
75
+
76
+ // The following rules are enabled in Airbnb config, but are already checked (more thoroughly) by the TypeScript compiler
77
+ // Some of the rules also fail in TypeScript files, for example: https://github.com/typescript-eslint/typescript-eslint/issues/662#issuecomment-507081586
78
+ // Rules are inspired by: https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
79
+ 'constructor-super': 'off',
80
+ 'getter-return': 'off',
81
+ 'no-const-assign': 'off',
82
+ 'no-dupe-args': 'off',
83
+ 'no-dupe-class-members': 'off',
84
+ 'no-dupe-keys': 'off',
85
+ 'no-func-assign': 'off',
86
+ 'no-import-assign': 'off',
87
+ 'no-new-symbol': 'off',
88
+ 'no-obj-calls': 'off',
89
+ 'no-redeclare': 'off',
90
+ 'no-setter-return': 'off',
91
+ 'no-this-before-super': 'off',
92
+ 'no-undef': 'off',
93
+ 'no-unreachable': 'off',
94
+ 'no-unsafe-negation': 'off',
95
+ 'valid-typeof': 'off',
96
+ // The following rules are enabled in Airbnb config, but are recommended to be disabled within TypeScript projects
97
+ // See: https://github.com/typescript-eslint/typescript-eslint/blob/13583e65f5973da2a7ae8384493c5e00014db51b/docs/linting/TROUBLESHOOTING.md#eslint-plugin-import
98
+ 'import/named': 'off',
99
+ 'import/no-named-as-default-member': 'off',
100
+ // Disable `import/no-unresolved`, see README.md for details
101
+ 'import/no-unresolved': 'off',
75
102
  },
76
103
  },
77
104
  ]