eslint-config-seek 13.1.0 → 14.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.
Files changed (4) hide show
  1. package/README.md +12 -16
  2. package/base.js +144 -130
  3. package/index.js +40 -38
  4. package/package.json +19 -23
package/README.md CHANGED
@@ -5,35 +5,31 @@
5
5
 
6
6
  This package includes the shareable ESLint configuration used by [SEEK](https://github.com/seek-oss/).
7
7
 
8
- ## Usage in sku Projects
8
+ ## Usage in sku and skuba Projects
9
9
 
10
- The easiest way to use this configuration is with [sku](https://github.com/seek-oss/sku), which includes it by default.
10
+ The easiest way to use this configuration is with [sku](https://github.com/seek-oss/sku) or [skuba](https://github.com/seek-oss/skuba).
11
11
 
12
- **You don’t need to install it separately in sku projects.**
12
+ **You don’t need to install it separately in sku and skuba projects.**
13
13
 
14
- ## Usage Outside of sku
14
+ ## Usage Outside of sku and skuba
15
15
 
16
- If you want to use this ESLint configuration in a project not built with sku, you can install it with following steps.
16
+ If you want to use this ESLint configuration in a project not built with sku or skuba, you can install it with following steps.
17
17
 
18
- First, install this package, ESLint and the necessary plugins listed in this project's [package.json](package.json).
18
+ First, install this package, and the necessary peer dependencies listed in this project's [package.json](package.json).
19
19
 
20
- Then create a file named `.eslintrc` with following contents in the root folder of your project:
20
+ Then create a file named `eslint.config.js` with the following contents in the root folder of your project:
21
21
 
22
- ```json
23
- {
24
- "extends": "seek"
25
- }
22
+ ```js
23
+ module.exports = require('eslint-config-seek');
26
24
  ```
27
25
 
28
26
  The default configuration includes support for React projects. For projects that are not based on React, the "base" configuration should be used instead:
29
27
 
30
- ```json
31
- {
32
- "extends": "seek/base"
33
- }
28
+ ```js
29
+ module.exports = require('eslint-config-seek/base');
34
30
  ```
35
31
 
36
- You can override the settings from `eslint-config-seek` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
32
+ You can override the settings from `eslint-config-seek` by editing the `eslint.config.js` file. Learn more about [configuring ESLint](https://eslint.org/docs/latest/use/configure/) on the ESLint website.
37
33
 
38
34
  ## License
39
35
 
package/base.js CHANGED
@@ -1,4 +1,9 @@
1
- const root = require('find-root')(process.cwd());
1
+ const importX = require('eslint-plugin-import-x');
2
+ const globals = require('globals');
3
+ const jestPlugin = require('eslint-plugin-jest');
4
+ const cypress = require('eslint-plugin-cypress');
5
+ const eslintConfigPrettier = require('eslint-config-prettier');
6
+ const tseslint = require('typescript-eslint');
2
7
 
3
8
  const OFF = 0;
4
9
  const ERROR = 2;
@@ -79,149 +84,158 @@ const baseRules = {
79
84
  const { js: jsExtensions, ts: tsExtensions } = require('./extensions');
80
85
  const allExtensions = [...jsExtensions, ...tsExtensions];
81
86
 
82
- /** @type {import('eslint').Linter.Config} */
83
- const baseConfig = {
84
- parser: '@babel/eslint-parser',
85
- parserOptions: {
86
- requireConfigFile: false,
87
- sourceType: 'module',
88
- },
89
- root: true,
90
- env: {
87
+ const settings = {
88
+ 'import-x/resolver': {
89
+ typescript: true,
91
90
  node: true,
92
91
  },
93
- plugins: ['import'],
94
- extends: [
95
- // this config enables eslint-plugin-import to resolve JavaScript and TypeScript files
96
- // https://github.com/import-js/eslint-plugin-import/blob/v2.26.0/config/typescript.js
97
- // Some rules provided by eslint-plugin-import e.g. `import/no-duplicates` don't work without it
98
- 'plugin:import/typescript',
99
- 'prettier',
100
- ],
101
- rules: {
102
- ...baseRules,
92
+ };
93
+
94
+ module.exports = [
95
+ eslintConfigPrettier,
96
+ {
97
+ plugins: {
98
+ 'import-x': importX,
99
+ },
103
100
  },
104
- overrides: [
105
- {
106
- // TypeScript config
107
- files: [`**/*.{${tsExtensions}}`],
108
- parser: '@typescript-eslint/parser',
101
+ importX.flatConfigs.typescript,
102
+ {
103
+ rules: importX.flatConfigs.errors.rules,
104
+ files: [`**/*.{${jsExtensions}}`],
105
+ },
106
+ {
107
+ rules: importX.flatConfigs.warnings.rules,
108
+ files: [`**/*.{${jsExtensions}}`],
109
+ },
110
+ {
111
+ languageOptions: {
112
+ globals: {
113
+ ...globals.node,
114
+ },
115
+
109
116
  parserOptions: {
110
- // https://github.com/typescript-eslint/typescript-eslint/issues/6544
111
- allowAutomaticSingleRunInference: true,
112
- ecmaVersion: 2022,
113
- project: true,
117
+ requireConfigFile: false,
118
+ ecmaVersion: 'latest',
114
119
  sourceType: 'module',
120
+ },
121
+ },
122
+ settings,
123
+ rules: baseRules,
124
+ },
125
+ ...[...tseslint.configs.recommended, ...tseslint.configs.stylistic].map(
126
+ (config) => ({
127
+ ...config,
128
+ files: [`**/*.{${tsExtensions}}`],
129
+ }),
130
+ ),
131
+ {
132
+ files: [`**/*.{${tsExtensions}}`],
133
+
134
+ languageOptions: {
135
+ parser: tseslint.parser,
136
+
137
+ parserOptions: {
138
+ projectService: true,
115
139
  warnOnUnsupportedTypeScriptVersion: false,
116
140
  },
117
- extends: [
118
- 'plugin:@typescript-eslint/recommended',
119
- 'plugin:@typescript-eslint/stylistic',
120
- 'prettier',
141
+ },
142
+ settings,
143
+ rules: {
144
+ '@typescript-eslint/array-type': [ERROR, { default: 'array-simple' }],
145
+ '@typescript-eslint/consistent-type-definitions': OFF,
146
+ '@typescript-eslint/no-unused-expressions': ERROR,
147
+ '@typescript-eslint/no-unused-vars': [
148
+ ERROR,
149
+ { argsIgnorePattern: '^_', ignoreRestSiblings: true },
121
150
  ],
122
- settings: {
123
- // adds comprehensive TypeScript support to eslint-plugin-import
124
- // https://github.com/import-js/eslint-import-resolver-typescript
125
- 'import/resolver': {
126
- typescript: {},
127
- },
128
- },
129
- rules: {
130
- '@typescript-eslint/array-type': [ERROR, { default: 'array-simple' }],
131
- '@typescript-eslint/consistent-type-definitions': OFF,
132
- '@typescript-eslint/no-unused-expressions': ERROR,
133
- '@typescript-eslint/no-unused-vars': [
134
- ERROR,
135
- { argsIgnorePattern: '^_', ignoreRestSiblings: true },
136
- ],
137
- '@typescript-eslint/no-use-before-define': OFF,
138
- '@typescript-eslint/no-non-null-assertion': OFF,
139
- '@typescript-eslint/ban-ts-comment': OFF,
140
- '@typescript-eslint/no-explicit-any': OFF,
141
- '@typescript-eslint/explicit-function-return-type': OFF,
142
- '@typescript-eslint/no-empty-function': OFF,
143
- '@typescript-eslint/no-empty-interface': OFF,
144
- '@typescript-eslint/no-inferrable-types': [
145
- ERROR,
146
- { ignoreParameters: true },
147
- ],
148
- // prefer TypeScript exhaustiveness checking
149
- // https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking
150
- 'default-case': OFF,
151
- 'arrow-body-style': [ERROR, 'as-needed'],
152
- // Use `typescript-eslint`'s no-shadow to avoid false positives with enums
153
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
154
- 'no-shadow': OFF,
155
- '@typescript-eslint/no-shadow': ERROR,
151
+ '@typescript-eslint/no-use-before-define': OFF,
152
+ '@typescript-eslint/no-non-null-assertion': OFF,
153
+ '@typescript-eslint/ban-ts-comment': OFF,
154
+ '@typescript-eslint/no-explicit-any': OFF,
155
+ '@typescript-eslint/explicit-function-return-type': OFF,
156
+ '@typescript-eslint/no-empty-function': OFF,
157
+ '@typescript-eslint/no-empty-interface': OFF,
158
+ '@typescript-eslint/no-inferrable-types': [
159
+ ERROR,
160
+ { ignoreParameters: true },
161
+ ],
162
+ // prefer TypeScript exhaustiveness checking
163
+ // https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking
164
+ 'default-case': OFF,
165
+ 'arrow-body-style': [ERROR, 'as-needed'],
166
+ // Use `typescript-eslint`'s no-shadow to avoid false positives with enums
167
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
168
+ 'no-shadow': OFF,
169
+ '@typescript-eslint/no-shadow': ERROR,
156
170
 
157
- // These two rules deal with autofixing type imports/exports
158
- // https://typescript-eslint.io/rules/consistent-type-imports
159
- '@typescript-eslint/consistent-type-imports': [
160
- ERROR,
161
- { fixStyle: 'inline-type-imports' },
162
- ],
163
- // https://typescript-eslint.io/rules/consistent-type-exports
164
- '@typescript-eslint/consistent-type-exports': [
165
- ERROR,
166
- { fixMixedExportsWithInlineTypeSpecifier: true },
167
- ],
168
- // https://typescript-eslint.io/rules/no-import-type-side-effects
169
- '@typescript-eslint/no-import-type-side-effects': ERROR,
171
+ // These two rules deal with autofixing type imports/exports
172
+ // https://typescript-eslint.io/rules/consistent-type-imports
173
+ '@typescript-eslint/consistent-type-imports': [
174
+ ERROR,
175
+ { fixStyle: 'inline-type-imports' },
176
+ ],
177
+ // https://typescript-eslint.io/rules/consistent-type-exports
178
+ '@typescript-eslint/consistent-type-exports': [
179
+ ERROR,
180
+ { fixMixedExportsWithInlineTypeSpecifier: true },
181
+ ],
182
+ // https://typescript-eslint.io/rules/no-import-type-side-effects
183
+ '@typescript-eslint/no-import-type-side-effects': ERROR,
170
184
 
171
- // This rule deals with merging multiple imports from the same module.
172
- // In this case, we want type imports to be inlined when merging with the other imports.
173
- // However, there is a pending PR which improves the behaviour of this rule https://github.com/import-js/eslint-plugin-import/pull/2716
174
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports
175
- 'import/no-duplicates': [ERROR, { 'prefer-inline': true }],
176
- },
185
+ // This rule deals with merging multiple imports from the same module.
186
+ // In this case, we want type imports to be inlined when merging with the other imports.
187
+ // However, there is a pending PR which improves the behaviour of this rule https://github.com/import-js/eslint-plugin-import/pull/2716
188
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports
189
+ 'import-x/no-duplicates': [ERROR, { 'prefer-inline': true }],
177
190
  },
178
- {
179
- // JavaScript config
180
- files: [`**/*.{${jsExtensions}}`],
181
- env: {
182
- es6: true,
183
- },
184
- extends: ['plugin:import/errors', 'plugin:import/warnings'],
185
- settings: {
186
- 'import/resolver': {
187
- node: {
188
- moduleDirectory: [root, 'node_modules'],
189
- },
190
- },
191
- },
192
- rules: {
193
- 'no-undef': ERROR,
194
- 'no-use-before-define': [ERROR, { functions: false }],
195
- 'no-unused-expressions': ERROR,
196
- 'import/no-unresolved': [
197
- ERROR,
198
- { commonjs: true, amd: true, ignore: ['.svg$', '^file?'] },
199
- ],
200
- 'import/no-duplicates': ERROR,
201
- },
191
+ },
192
+ {
193
+ files: [`**/*.{${jsExtensions}}`],
194
+ languageOptions: {
195
+ globals: {},
202
196
  },
203
- {
204
- // Jest config
205
- files: [
206
- `**/__tests__/**/*.{${allExtensions}}`,
207
- `**/*.@(spec|test).{${allExtensions}}`,
197
+ settings,
198
+ rules: {
199
+ 'no-undef': ERROR,
200
+ 'no-use-before-define': [ERROR, { functions: false }],
201
+ 'no-unused-expressions': ERROR,
202
+ 'import-x/no-unresolved': [
203
+ ERROR,
204
+ { commonjs: true, amd: true, ignore: ['.svg$', '^file?'] },
208
205
  ],
209
- env: {
210
- jest: true,
206
+ 'import-x/no-duplicates': ERROR,
207
+ },
208
+ },
209
+ {
210
+ ...jestPlugin.configs['flat/recommended'],
211
+ files: [
212
+ `**/__tests__/**/*.{${allExtensions}}`,
213
+ `**/*.@(spec|test).{${allExtensions}}`,
214
+ ],
215
+ },
216
+ {
217
+ files: [
218
+ `**/__tests__/**/*.{${allExtensions}}`,
219
+ `**/*.@(spec|test).{${allExtensions}}`,
220
+ ],
221
+ plugins: { jest: jestPlugin },
222
+ languageOptions: {
223
+ globals: {
224
+ ...globals.jest,
211
225
  },
212
- extends: ['plugin:jest/recommended'],
213
- plugins: ['jest'],
214
226
  },
215
- {
216
- // Cypress config
217
- files: [`**/cypress/**/*.{${allExtensions}}`],
218
- extends: ['plugin:cypress/recommended'],
219
- env: {
220
- 'cypress/globals': true,
227
+ },
228
+ {
229
+ ...cypress.configs.recommended,
230
+ files: [`**/cypress/**/*.{${allExtensions}}`],
231
+ },
232
+ {
233
+ files: [`**/cypress/**/*.{${allExtensions}}`],
234
+ plugins: { cypress },
235
+ languageOptions: {
236
+ globals: {
237
+ ...cypress.environments.globals.globals,
221
238
  },
222
- plugins: ['cypress'],
223
239
  },
224
- ],
225
- };
226
-
227
- module.exports = baseConfig;
240
+ },
241
+ ];
package/index.js CHANGED
@@ -1,3 +1,10 @@
1
+ const react = require('eslint-plugin-react');
2
+ const reactHooks = require('eslint-plugin-react-hooks');
3
+ const base = require('./base');
4
+ const { fixupPluginRules } = require('@eslint/compat');
5
+
6
+ const globals = require('globals');
7
+
1
8
  const OFF = 0;
2
9
  const ERROR = 2;
3
10
 
@@ -16,46 +23,41 @@ const reactRules = {
16
23
  ],
17
24
  };
18
25
 
19
- /** @type {import('eslint').Linter.Config} */
20
- const eslintConfig = {
21
- env: {
22
- browser: true,
23
- },
24
- settings: {
25
- react: {
26
- version: 'detect',
26
+ module.exports = [
27
+ react.configs.flat.recommended,
28
+ react.configs.flat['jsx-runtime'],
29
+ ...base,
30
+ {
31
+ plugins: {
32
+ react,
33
+ 'react-hooks': fixupPluginRules(reactHooks),
27
34
  },
28
- },
29
- plugins: ['react', 'react-hooks'],
30
- extends: [
31
- 'plugin:react/recommended',
32
- 'plugin:react/jsx-runtime',
33
- './base.js',
34
- ],
35
- parserOptions: {
36
- babelOptions: {
37
- presets: [require.resolve('@babel/preset-react')],
35
+
36
+ languageOptions: {
37
+ globals: globals.browser,
38
38
  },
39
- },
40
- rules: {
41
- ...reactRules,
42
- },
43
- overrides: [
44
- {
45
- // temporary override until everybody removes the React import
46
- files: [`**/*.tsx`],
47
- rules: {
48
- '@typescript-eslint/no-unused-vars': [
49
- ERROR,
50
- {
51
- argsIgnorePattern: '^_',
52
- ignoreRestSiblings: true,
53
- varsIgnorePattern: '^React$',
54
- },
55
- ],
39
+
40
+ settings: {
41
+ react: {
42
+ version: 'detect',
56
43
  },
57
44
  },
58
- ],
59
- };
60
45
 
61
- module.exports = eslintConfig;
46
+ rules: reactRules,
47
+ },
48
+ {
49
+ files: ['**/*.tsx'],
50
+
51
+ rules: {
52
+ // temporary override until everybody removes the React import
53
+ '@typescript-eslint/no-unused-vars': [
54
+ ERROR,
55
+ {
56
+ argsIgnorePattern: '^_',
57
+ ignoreRestSiblings: true,
58
+ varsIgnorePattern: '^React$',
59
+ },
60
+ ],
61
+ },
62
+ },
63
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-seek",
3
- "version": "13.1.0",
3
+ "version": "14.0.0",
4
4
  "description": "ESLint configuration used by SEEK",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -19,41 +19,37 @@
19
19
  },
20
20
  "homepage": "https://github.com/seek-oss/eslint-config-seek#readme",
21
21
  "dependencies": {
22
- "@babel/core": "^7.22.6",
23
- "@babel/eslint-parser": "^7.22.6",
24
- "@babel/preset-react": "^7.22.5",
25
- "eslint-plugin-cypress": "^3.0.0",
26
- "@typescript-eslint/eslint-plugin": "^7.2.0",
27
- "@typescript-eslint/parser": "^7.2.0",
28
- "eslint-config-prettier": "^8.8.0",
29
- "eslint-import-resolver-typescript": "3.5.5",
30
- "eslint-plugin-import": "^2.27.5",
31
- "eslint-plugin-jest": "^27.9.0",
32
- "eslint-plugin-react": "^7.32.2",
33
- "eslint-plugin-react-hooks": "^4.6.0",
34
- "find-root": "^1.1.0"
22
+ "@eslint/compat": "^1.1.1",
23
+ "typescript-eslint": "^8.6.0",
24
+ "eslint-config-prettier": "^9.1.0",
25
+ "eslint-import-resolver-typescript": "^3.6.3",
26
+ "eslint-plugin-cypress": "^3.5.0",
27
+ "eslint-plugin-import-x": "^4.2.1",
28
+ "eslint-plugin-jest": "^28.8.0",
29
+ "eslint-plugin-react": "^7.35.0",
30
+ "eslint-plugin-react-hooks": "^4.6.2",
31
+ "globals": "^15.9.0"
35
32
  },
36
33
  "devDependencies": {
37
- "@changesets/cli": "^2.26.2",
38
- "@changesets/get-github-info": "^0.5.2",
39
- "eslint": "^8.56.0",
40
- "prettier": "^2.8.4",
41
- "typescript": "~5.4.2"
34
+ "@changesets/cli": "^2.27.7",
35
+ "@changesets/get-github-info": "^0.6.0",
36
+ "eslint": "^9.8.0",
37
+ "prettier": "^3.3.3",
38
+ "typescript": "~5.5.4"
42
39
  },
43
40
  "peerDependencies": {
44
- "eslint": ">=8.56.0",
45
- "typescript": ">=4.7.5"
41
+ "eslint": ">=9.9.1",
42
+ "typescript": ">=5.5.4"
46
43
  },
47
44
  "engines": {
48
45
  "node": ">=18.18.0"
49
46
  },
50
- "packageManager": "pnpm@8.6.6",
51
47
  "volta": {
52
48
  "node": "18.18.0"
53
49
  },
54
50
  "scripts": {
55
51
  "release": "changeset publish",
56
- "test": "eslint . && eslint --config base.js .",
52
+ "test": "eslint --config index.js . && eslint --config base.js .",
57
53
  "changeset-version": "changeset version && prettier --write ."
58
54
  }
59
55
  }