eslint-config-seek 0.0.0-rulesdir-20230605003131 → 0.0.0-try-fix-20240925053654

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/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,12 +1,13 @@
1
- const path = require('path');
2
- 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');
3
7
 
4
8
  const OFF = 0;
5
9
  const ERROR = 2;
6
10
 
7
- const rulesDirPlugin = require('eslint-plugin-rulesdir');
8
- rulesDirPlugin.RULES_DIR = path.resolve('rules', path.dirname(__filename));
9
-
10
11
  const baseRules = {
11
12
  // Possible Errors
12
13
  'no-console': ERROR,
@@ -24,6 +25,7 @@ const baseRules = {
24
25
  'no-eval': ERROR,
25
26
  'no-extend-native': ERROR,
26
27
  'no-extra-bind': ERROR,
28
+ 'no-fallthrough': ERROR,
27
29
  'no-floating-decimal': ERROR,
28
30
  'no-implicit-coercion': ERROR,
29
31
  'no-implied-eval': ERROR,
@@ -82,150 +84,160 @@ const baseRules = {
82
84
  const { js: jsExtensions, ts: tsExtensions } = require('./extensions');
83
85
  const allExtensions = [...jsExtensions, ...tsExtensions];
84
86
 
85
- /** @type {import('eslint').Linter.Config} */
86
- const baseConfig = {
87
- parser: '@babel/eslint-parser',
88
- parserOptions: {
89
- requireConfigFile: false,
90
- sourceType: 'module',
91
- },
92
- root: true,
93
- env: {
87
+ const settings = {
88
+ 'import-x/resolver': {
89
+ typescript: true,
94
90
  node: true,
95
91
  },
96
- plugins: ['import'],
97
- extends: [
98
- // this config enables eslint-plugin-import to resolve JavaScript and TypeScript files
99
- // https://github.com/import-js/eslint-plugin-import/blob/v2.26.0/config/typescript.js
100
- // Some rules provided by eslint-plugin-import e.g. `import/no-duplicates` don't work without it
101
- 'plugin:import/typescript',
102
- 'prettier',
103
- ],
104
- rules: {
105
- ...baseRules,
92
+ };
93
+
94
+ module.exports = [
95
+ eslintConfigPrettier,
96
+ {
97
+ plugins: {
98
+ 'import-x': importX,
99
+ jest: jestPlugin,
100
+ cypress,
101
+ '@typescript-eslint': tseslint.plugin,
102
+ },
106
103
  },
107
- overrides: [
108
- {
109
- // TypeScript config
110
- files: [`**/*.{${tsExtensions}}`],
111
- parser: '@typescript-eslint/parser',
104
+ importX.flatConfigs.typescript,
105
+ {
106
+ rules: importX.flatConfigs.errors.rules,
107
+ files: [`**/*.{${jsExtensions}}`],
108
+ },
109
+ {
110
+ rules: importX.flatConfigs.warnings.rules,
111
+ files: [`**/*.{${jsExtensions}}`],
112
+ },
113
+ {
114
+ languageOptions: {
115
+ globals: {
116
+ ...globals.node,
117
+ },
118
+
112
119
  parserOptions: {
113
- ecmaVersion: 2018,
120
+ requireConfigFile: false,
121
+ ecmaVersion: 'latest',
114
122
  sourceType: 'module',
115
- project: true,
116
- },
117
- extends: [
118
- 'plugin:@typescript-eslint/eslint-recommended',
119
- 'plugin:@typescript-eslint/recommended',
120
- 'prettier',
121
- ],
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
123
  },
129
- rules: {
130
- '@typescript-eslint/no-unused-expressions': ERROR,
131
- '@typescript-eslint/no-unused-vars': [
132
- ERROR,
133
- { argsIgnorePattern: '^_', ignoreRestSiblings: true },
134
- ],
135
- '@typescript-eslint/no-use-before-define': OFF,
136
- '@typescript-eslint/no-non-null-assertion': OFF,
137
- '@typescript-eslint/ban-ts-comment': OFF,
138
- '@typescript-eslint/no-explicit-any': OFF,
139
- '@typescript-eslint/explicit-function-return-type': OFF,
140
- '@typescript-eslint/no-empty-function': OFF,
141
- '@typescript-eslint/no-empty-interface': OFF,
142
- '@typescript-eslint/no-inferrable-types': [
143
- ERROR,
144
- { ignoreParameters: true },
145
- ],
146
- // prefer TypeScript exhaustiveness checking
147
- // https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking
148
- 'default-case': OFF,
149
- 'arrow-body-style': [ERROR, 'as-needed'],
150
- // Use `typescript-eslint`'s no-shadow to avoid false positives with enums
151
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
152
- 'no-shadow': OFF,
153
- '@typescript-eslint/no-shadow': ERROR,
124
+ },
125
+ settings,
126
+ rules: baseRules,
127
+ },
128
+ ...[...tseslint.configs.recommended, ...tseslint.configs.stylistic].map(
129
+ (config) => ({
130
+ ...config,
131
+ plugins: undefined,
132
+ files: [`**/*.{${tsExtensions}}`],
133
+ }),
134
+ ),
135
+ {
136
+ files: [`**/*.{${tsExtensions}}`],
154
137
 
155
- // These two rules deal with autofixing type imports/exports
156
- // https://typescript-eslint.io/rules/consistent-type-imports
157
- '@typescript-eslint/consistent-type-imports': [
158
- ERROR,
159
- { fixStyle: 'inline-type-imports' },
160
- ],
161
- // https://typescript-eslint.io/rules/consistent-type-exports
162
- '@typescript-eslint/consistent-type-exports': [
163
- ERROR,
164
- { fixMixedExportsWithInlineTypeSpecifier: true },
165
- ],
166
- // https://typescript-eslint.io/rules/no-import-type-side-effects
167
- '@typescript-eslint/no-import-type-side-effects': ERROR,
138
+ languageOptions: {
139
+ parser: tseslint.parser,
168
140
 
169
- // This rule deals with merging multiple imports from the same module.
170
- // In this case, we want type imports to be inlined when merging with the other imports.
171
- // However, there is a pending PR which improves the behaviour of this rule https://github.com/import-js/eslint-plugin-import/pull/2716
172
- // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports
173
- 'import/no-duplicates': [ERROR, { 'prefer-inline': true }],
141
+ parserOptions: {
142
+ projectService: true,
143
+ warnOnUnsupportedTypeScriptVersion: false,
174
144
  },
175
145
  },
176
- {
177
- // JavaScript config
178
- files: [`**/*.{${jsExtensions}}`],
179
- env: {
180
- es6: true,
181
- },
182
- extends: ['plugin:import/errors', 'plugin:import/warnings'],
183
- settings: {
184
- 'import/resolver': {
185
- node: {
186
- moduleDirectory: [root, path.join(root, 'node_modules')],
187
- },
188
- },
189
- },
190
- rules: {
191
- 'no-undef': ERROR,
192
- 'no-use-before-define': [ERROR, { functions: false }],
193
- 'no-unused-expressions': ERROR,
194
- 'import/no-unresolved': [
195
- ERROR,
196
- { commonjs: true, amd: true, ignore: ['.svg$', '^file?'] },
197
- ],
198
- 'import/no-duplicates': ERROR,
199
- },
146
+ settings,
147
+ rules: {
148
+ '@typescript-eslint/array-type': [ERROR, { default: 'array-simple' }],
149
+ '@typescript-eslint/consistent-type-definitions': OFF,
150
+ '@typescript-eslint/no-unused-expressions': ERROR,
151
+ '@typescript-eslint/no-unused-vars': [
152
+ ERROR,
153
+ { argsIgnorePattern: '^_', ignoreRestSiblings: true },
154
+ ],
155
+ '@typescript-eslint/no-use-before-define': OFF,
156
+ '@typescript-eslint/no-non-null-assertion': OFF,
157
+ '@typescript-eslint/ban-ts-comment': OFF,
158
+ '@typescript-eslint/no-explicit-any': OFF,
159
+ '@typescript-eslint/explicit-function-return-type': OFF,
160
+ '@typescript-eslint/no-empty-function': OFF,
161
+ '@typescript-eslint/no-empty-interface': OFF,
162
+ '@typescript-eslint/no-inferrable-types': [
163
+ ERROR,
164
+ { ignoreParameters: true },
165
+ ],
166
+ // prefer TypeScript exhaustiveness checking
167
+ // https://www.typescriptlang.org/docs/handbook/advanced-types.html#exhaustiveness-checking
168
+ 'default-case': OFF,
169
+ 'arrow-body-style': [ERROR, 'as-needed'],
170
+ // Use `typescript-eslint`'s no-shadow to avoid false positives with enums
171
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-shadow.md
172
+ 'no-shadow': OFF,
173
+ '@typescript-eslint/no-shadow': ERROR,
174
+
175
+ // These two rules deal with autofixing type imports/exports
176
+ // https://typescript-eslint.io/rules/consistent-type-imports
177
+ '@typescript-eslint/consistent-type-imports': [
178
+ ERROR,
179
+ { fixStyle: 'inline-type-imports' },
180
+ ],
181
+ // https://typescript-eslint.io/rules/consistent-type-exports
182
+ '@typescript-eslint/consistent-type-exports': [
183
+ ERROR,
184
+ { fixMixedExportsWithInlineTypeSpecifier: true },
185
+ ],
186
+ // https://typescript-eslint.io/rules/no-import-type-side-effects
187
+ '@typescript-eslint/no-import-type-side-effects': ERROR,
188
+
189
+ // This rule deals with merging multiple imports from the same module.
190
+ // In this case, we want type imports to be inlined when merging with the other imports.
191
+ // However, there is a pending PR which improves the behaviour of this rule https://github.com/import-js/eslint-plugin-import/pull/2716
192
+ // https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports
193
+ 'import-x/no-duplicates': [ERROR, { 'prefer-inline': true }],
200
194
  },
201
- {
202
- // Jest config
203
- files: [
204
- `**/__tests__/**/*.{${allExtensions}}`,
205
- `**/*.@(spec|test).{${allExtensions}}`,
195
+ },
196
+ {
197
+ files: [`**/*.{${jsExtensions}}`],
198
+ languageOptions: {
199
+ globals: {},
200
+ },
201
+ settings,
202
+ rules: {
203
+ 'no-undef': ERROR,
204
+ 'no-use-before-define': [ERROR, { functions: false }],
205
+ 'no-unused-expressions': ERROR,
206
+ 'import-x/no-unresolved': [
207
+ ERROR,
208
+ { commonjs: true, amd: true, ignore: ['.svg$', '^file?'] },
206
209
  ],
207
- env: {
208
- jest: true,
209
- },
210
- extends: ['plugin:jest/recommended'],
211
- plugins: ['jest'],
210
+ 'import-x/no-duplicates': ERROR,
212
211
  },
213
- {
214
- // Cypress config
215
- files: [`**/cypress/**/*.{${allExtensions}}`],
216
- // eslint-plugin-cypress doesn't support ESLint v8.
217
- // Use fork by `@finsit` until this is solved.
218
- // https://github.com/cypress-io/eslint-plugin-cypress/issues/89
219
- extends: ['plugin:@finsit/cypress/recommended'],
220
- env: {
221
- '@finsit/cypress/globals': true,
212
+ },
213
+ {
214
+ ...jestPlugin.configs['flat/recommended'],
215
+ files: [
216
+ `**/__tests__/**/*.{${allExtensions}}`,
217
+ `**/*.@(spec|test).{${allExtensions}}`,
218
+ ],
219
+ },
220
+ {
221
+ files: [
222
+ `**/__tests__/**/*.{${allExtensions}}`,
223
+ `**/*.@(spec|test).{${allExtensions}}`,
224
+ ],
225
+ languageOptions: {
226
+ globals: {
227
+ ...globals.jest,
222
228
  },
223
- plugins: ['@finsit/cypress', 'rulesdir'],
224
- rules: {
225
- 'rulesdir/unsafe-to-chain-command': ERROR,
229
+ },
230
+ },
231
+ {
232
+ ...cypress.configs.recommended,
233
+ files: [`**/cypress/**/*.{${allExtensions}}`],
234
+ },
235
+ {
236
+ files: [`**/cypress/**/*.{${allExtensions}}`],
237
+ languageOptions: {
238
+ globals: {
239
+ ...cypress.environments.globals.globals,
226
240
  },
227
241
  },
228
- ],
229
- };
230
-
231
- module.exports = baseConfig;
242
+ },
243
+ ];
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
 
@@ -10,28 +17,47 @@ const reactRules = {
10
17
  'react/no-children-prop': ERROR,
11
18
  'react/display-name': OFF,
12
19
  'react/prop-types': OFF,
20
+ 'react/jsx-curly-brace-presence': [
21
+ ERROR,
22
+ { props: 'never', children: 'ignore', propElementValues: 'always' },
23
+ ],
13
24
  };
14
25
 
15
- /** @type {import('eslint').Linter.Config} */
16
- const eslintConfig = {
17
- env: {
18
- browser: true,
19
- },
20
- settings: {
21
- react: {
22
- 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),
23
34
  },
24
- },
25
- plugins: ['react', 'react-hooks'],
26
- extends: ['plugin:react/recommended', './base.js'],
27
- parserOptions: {
28
- babelOptions: {
29
- presets: [require.resolve('@babel/preset-react')],
35
+
36
+ languageOptions: {
37
+ globals: globals.browser,
30
38
  },
39
+
40
+ settings: {
41
+ react: {
42
+ version: 'detect',
43
+ },
44
+ },
45
+
46
+ rules: reactRules,
31
47
  },
32
- rules: {
33
- ...reactRules,
34
- },
35
- };
48
+ {
49
+ files: ['**/*.tsx'],
36
50
 
37
- module.exports = eslintConfig;
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,13 +1,12 @@
1
1
  {
2
2
  "name": "eslint-config-seek",
3
- "version": "0.0.0-rulesdir-20230605003131",
3
+ "version": "0.0.0-try-fix-20240925053654",
4
4
  "description": "ESLint configuration used by SEEK",
5
5
  "main": "index.js",
6
6
  "files": [
7
7
  "index.js",
8
8
  "base.js",
9
- "extensions.js",
10
- "rules/*"
9
+ "extensions.js"
11
10
  ],
12
11
  "repository": {
13
12
  "type": "git",
@@ -20,35 +19,33 @@
20
19
  },
21
20
  "homepage": "https://github.com/seek-oss/eslint-config-seek#readme",
22
21
  "dependencies": {
23
- "@babel/core": "^7.21.0",
24
- "@babel/eslint-parser": "^7.19.1",
25
- "@babel/preset-react": "^7.18.6",
26
- "@finsit/eslint-plugin-cypress": "^3.1.1",
27
- "@typescript-eslint/eslint-plugin": "^5.53.0",
28
- "@typescript-eslint/parser": "^5.53.0",
29
- "eslint-config-prettier": "^8.6.0",
30
- "eslint-import-resolver-typescript": "3.5.3",
31
- "eslint-plugin-import": "^2.27.5",
32
- "eslint-plugin-jest": "^27.2.1",
33
- "eslint-plugin-react": "^7.32.2",
34
- "eslint-plugin-react-hooks": "^4.6.0",
35
- "eslint-plugin-rulesdir": "^0.2.2",
36
- "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"
37
32
  },
38
33
  "devDependencies": {
39
- "@changesets/cli": "^2.26.0",
40
- "@changesets/get-github-info": "^0.5.2",
41
- "eslint": "^8.34.0",
42
- "prettier": "^2.8.4",
43
- "typescript": "~4.9.5"
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"
44
39
  },
45
40
  "peerDependencies": {
46
- "eslint": ">=6",
47
- "typescript": ">=4.5"
41
+ "eslint": ">=9.9.1",
42
+ "typescript": ">=5.5.4"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.18.0"
48
46
  },
49
- "packageManager": "pnpm@8.5.1",
50
47
  "volta": {
51
- "node": "16.19.1"
48
+ "node": "18.18.0"
52
49
  },
53
50
  "scripts": {
54
51
  "release": "changeset publish",
@@ -1,88 +0,0 @@
1
- /** This rule is copied from the original `eslint-plugin-cypress` so we can use the fork (which
2
- * supports eslint 8) while having the same recommended rules as the upstream
3
- * https://github.com/foretagsplatsen/eslint-plugin-cypress
4
- * https://github.com/cypress-io/eslint-plugin-cypress/blob/c626ad543f65babf1def5caabd1bc9bb9900d2c7/lib/rules/unsafe-to-chain-command.js
5
- */
6
- // eslint-disable-next-line strict
7
- 'use strict';
8
-
9
- module.exports = {
10
- meta: {
11
- docs: {
12
- description: 'Actions should be in the end of chains, not in the middle',
13
- category: 'Possible Errors',
14
- recommended: true,
15
- url: 'https://docs.cypress.io/guides/core-concepts/retry-ability#Actions-should-be-at-the-end-of-chains-not-the-middle',
16
- },
17
- schema: [],
18
- messages: {
19
- unexpected:
20
- 'It is unsafe to chain further commands that rely on the subject after this command. It is best to split the chain, chaining again from `cy.` in a next command line.',
21
- },
22
- },
23
- create(context) {
24
- return {
25
- CallExpression(node) {
26
- if (
27
- isRootCypress(node) &&
28
- isActionUnsafeToChain(node) &&
29
- node.parent.type === 'MemberExpression'
30
- ) {
31
- context.report({ node, messageId: 'unexpected' });
32
- }
33
- },
34
- };
35
- },
36
- };
37
-
38
- function isRootCypress(node) {
39
- while (node.type === 'CallExpression') {
40
- if (node.callee.type !== 'MemberExpression') {
41
- return false;
42
- }
43
-
44
- if (
45
- node.callee.object.type === 'Identifier' &&
46
- node.callee.object.name === 'cy'
47
- ) {
48
- return true;
49
- }
50
-
51
- // eslint-disable-next-line no-param-reassign
52
- node = node.callee.object;
53
- }
54
-
55
- return false;
56
- }
57
-
58
- function isActionUnsafeToChain(node) {
59
- // commands listed in the documentation with text: 'It is unsafe to chain further commands that rely on the subject after xxx'
60
- const unsafeToChainActions = [
61
- 'blur',
62
- 'clear',
63
- 'click',
64
- 'check',
65
- 'dblclick',
66
- 'each',
67
- 'focus',
68
- 'rightclick',
69
- 'screenshot',
70
- 'scrollIntoView',
71
- 'scrollTo',
72
- 'select',
73
- 'selectFile',
74
- 'spread',
75
- 'submit',
76
- 'type',
77
- 'trigger',
78
- 'uncheck',
79
- 'within',
80
- ];
81
-
82
- return (
83
- node.callee &&
84
- node.callee.property &&
85
- node.callee.property.type === 'Identifier' &&
86
- unsafeToChainActions.includes(node.callee.property.name)
87
- );
88
- }