@autoguru/eslint-plugin 1.5.0 → 2.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 CHANGED
@@ -1,34 +1,49 @@
1
1
  # @autoguru/eslint-plugin
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 0f9d788: Migrates to Eslint 9, maintaining the commonly needed rules in config
8
+ and extracting project-specific rules. The plugin continues to export the
9
+ legacy configs in common-js, the modern configs are exported from
10
+ `@autoguru/eslint-plugin/config`.
11
+
12
+ ## 1.6.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 8297630: Dependency upgrades
17
+
3
18
  ## 1.5.0
4
19
 
5
20
  ### Minor Changes
6
21
 
7
- - 05747b1: Added nx workspaces
22
+ - 05747b1: Added nx workspaces
8
23
 
9
24
  ## 1.4.0
10
25
 
11
26
  ### Minor Changes
12
27
 
13
- - de55945: Adds sonarjs eslint rules to AutoGuru typescript eslint
28
+ - de55945: Adds sonarjs eslint rules to AutoGuru typescript eslint
14
29
 
15
30
  ## 1.3.2
16
31
 
17
32
  ### Patch Changes
18
33
 
19
- - ae9cd96: Removes next eslint
34
+ - ae9cd96: Removes next eslint
20
35
 
21
36
  ## 1.3.1
22
37
 
23
38
  ### Patch Changes
24
39
 
25
- - ebee6d4: GDU: Adds CSP rules @autoguru/eslint-plugin: Adds nextjs defaults
40
+ - ebee6d4: GDU: Adds CSP rules @autoguru/eslint-plugin: Adds nextjs defaults
26
41
 
27
42
  ## 1.3.0
28
43
 
29
44
  ### Minor Changes
30
45
 
31
- - d80a10b: Unicorn eslint rules: Upgraded to v33
46
+ - d80a10b: Unicorn eslint rules: Upgraded to v33
32
47
 
33
48
  Prettier: Upgrades to v2.3
34
49
 
@@ -36,47 +51,47 @@
36
51
 
37
52
  ### Minor Changes
38
53
 
39
- - df57e1a: Upgrades eslint packages
54
+ - df57e1a: Upgrades eslint packages
40
55
 
41
56
  ## 1.1.5
42
57
 
43
58
  ### Patch Changes
44
59
 
45
- - 3827266: Prettier just has itself (no more /react)
60
+ - 3827266: Prettier just has itself (no more /react)
46
61
 
47
62
  ## 1.1.4
48
63
 
49
64
  ### Patch Changes
50
65
 
51
- - 919e4a0: Upgraded all dev and prod deps
66
+ - 919e4a0: Upgraded all dev and prod deps
52
67
 
53
68
  ## 1.1.3
54
69
 
55
70
  ### Patch Changes
56
71
 
57
- - f1dd447: The react-in-scope rule is now mute
72
+ - f1dd447: The react-in-scope rule is now mute
58
73
 
59
74
  ## 1.1.2
60
75
 
61
76
  ### Patch Changes
62
77
 
63
- - 4260eb3: Bumps all deps
78
+ - 4260eb3: Bumps all deps
64
79
 
65
80
  ## 1.1.1
66
81
 
67
82
  ### Patch Changes
68
83
 
69
- - 5567db1: Fixes some eslint rules breaking our things
84
+ - 5567db1: Fixes some eslint rules breaking our things
70
85
 
71
86
  ## 1.1.0
72
87
 
73
88
  ### Minor Changes
74
89
 
75
- - bf0d849: Smaller more simple eslint config. Using less plugins, to help
76
- improve eslint runs and also more granular control.
90
+ - bf0d849: Smaller more simple eslint config. Using less plugins, to help
91
+ improve eslint runs and also more granular control.
77
92
 
78
93
  ## 1.0.85
79
94
 
80
95
  ### Patch Changes
81
96
 
82
- - b0d77f1: Mass upgrade of dependencies
97
+ - b0d77f1: Mass upgrade of dependencies
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line unicorn/prefer-module
2
1
  module.exports = {
3
2
  extends: ['plugin:import/errors'],
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/prefer-module */
2
1
  module.exports = {
3
2
  parserOptions: {
4
3
  sourceType: 'module',
package/configs/jest.js CHANGED
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line unicorn/prefer-module
2
1
  module.exports = {
3
2
  extends: ['plugin:jest/recommended'],
4
3
 
package/configs/react.js CHANGED
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line unicorn/prefer-module
2
1
  module.exports = {
3
2
  extends: ['plugin:react/recommended'],
4
3
 
@@ -1,4 +1,3 @@
1
- // eslint-disable-next-line unicorn/prefer-module
2
1
  module.exports = {
3
2
  extends: [
4
3
  'plugin:@typescript-eslint/eslint-recommended',
@@ -0,0 +1,177 @@
1
+ import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2
+ import { FlatCompat } from '@eslint/eslintrc';
3
+ import js from '@eslint/js';
4
+ import tsParser from '@typescript-eslint/parser';
5
+ import reactEslint from 'eslint-plugin-react';
6
+ import reactHooks from 'eslint-plugin-react-hooks';
7
+ import jsxA11Y from 'eslint-plugin-jsx-a11y';
8
+ import sonarjs from 'eslint-plugin-sonarjs';
9
+ import tseslint from 'typescript-eslint';
10
+ import globals from 'globals';
11
+
12
+ import path from 'node:path';
13
+ import { fileURLToPath } from 'node:url';
14
+
15
+ const __filename = fileURLToPath(import.meta.url);
16
+ const __dirname = path.dirname(__filename);
17
+ const compat = new FlatCompat({
18
+ baseDirectory: __dirname,
19
+ recommendedConfig: js.configs.recommended,
20
+ allConfig: js.configs.all,
21
+ });
22
+
23
+ // Eslint configs for import statements
24
+ /** @type {import('eslint').Linter.Config[]} */
25
+ export const imports = [
26
+ ...fixupConfigRules(compat.extends('plugin:import/errors')),
27
+ {
28
+ rules: {
29
+ 'import/order': [
30
+ 'error',
31
+ {
32
+ 'newlines-between': 'always',
33
+ alphabetize: { order: 'asc' },
34
+ groups: [
35
+ 'builtin',
36
+ 'external',
37
+ 'internal',
38
+ 'parent',
39
+ 'sibling',
40
+ 'index',
41
+ ],
42
+ pathGroups: [
43
+ {
44
+ pattern: '*.+(treat)',
45
+ group: 'index',
46
+ position: 'after',
47
+ patternOptions: { matchBase: true },
48
+ },
49
+ ],
50
+ },
51
+ ],
52
+ 'import/no-unresolved': 'off', // Just too many problems...
53
+ 'import/default': 'off',
54
+ 'import/extensions': [
55
+ 'error',
56
+ 'never',
57
+ {
58
+ graphql: 'always',
59
+ },
60
+ ],
61
+ 'import/no-duplicates': 'error',
62
+ },
63
+ },
64
+ ];
65
+
66
+ // Eslint base config including import
67
+ /** @type {import('eslint').Linter.Config[]} */
68
+ export const base = [
69
+ js.configs.recommended,
70
+ ...imports,
71
+ ...fixupConfigRules(
72
+ compat.extends(
73
+ 'plugin:unicorn/recommended',
74
+ 'plugin:promise/recommended',
75
+ 'prettier',
76
+ ),
77
+ ),
78
+ {
79
+ languageOptions: {
80
+ globals: globals.browser,
81
+ },
82
+ rules: {
83
+ 'no-sparse-arrays': 'warn',
84
+ 'unicorn/filename-case': 'off',
85
+ 'unicorn/prevent-abbreviations': 'off',
86
+ 'unicorn/no-null': 'off',
87
+ 'unicorn/no-reduce': 'off',
88
+ 'unicorn/no-array-reduce': 'off',
89
+ 'unicorn/no-array-for-each': 'off',
90
+ 'unicorn/no-array-push-push': 'off',
91
+ 'unicorn/prefer-global-this': 'off',
92
+ 'unicorn/prefer-spread': 'warn',
93
+ },
94
+ },
95
+ ];
96
+
97
+ // Eslint react plugins, settings and rules
98
+ /** @type {import('eslint').Linter.Config[]} */
99
+ export const react = [
100
+ ...fixupConfigRules(
101
+ compat.extends(
102
+ 'plugin:react/recommended',
103
+ 'plugin:react-hooks/recommended',
104
+ ),
105
+ ),
106
+ {
107
+ plugins: {
108
+ react: fixupPluginRules(reactEslint),
109
+ 'react-hooks': fixupPluginRules(reactHooks),
110
+ 'jsx-a11y': jsxA11Y,
111
+ },
112
+ settings: {
113
+ react: {
114
+ version: 'detect',
115
+ },
116
+ },
117
+ rules: {
118
+ 'react/no-array-index-key': 'warn',
119
+ 'react/prop-types': 'off',
120
+ 'react/display-name': 'off',
121
+ },
122
+ },
123
+ ];
124
+
125
+ // TypeScript plugins, and SonarJS plugin settings and rules
126
+ /** @type {import('eslint').Linter.Config[]} */
127
+ export const typescript = [
128
+ ...tseslint.configs.recommended,
129
+ ...fixupConfigRules(
130
+ compat.extends(
131
+ 'plugin:import/typescript',
132
+ 'plugin:sonarjs/recommended-legacy',
133
+ ),
134
+ ),
135
+ {
136
+ plugins: {
137
+ sonarjs: fixupPluginRules(sonarjs),
138
+ },
139
+ languageOptions: {
140
+ parser: tsParser,
141
+ ecmaVersion: 2020,
142
+ sourceType: 'module',
143
+ parserOptions: {
144
+ ecmaFeatures: {
145
+ jsx: true,
146
+ },
147
+ },
148
+ },
149
+ settings: {
150
+ 'import/resolver': {
151
+ typescript: {},
152
+ },
153
+ },
154
+ rules: {
155
+ 'sonarjs/no-duplicate-string': 'warn',
156
+ 'sonarjs/no-nested-template-literals': 'warn',
157
+ 'sonarjs/slow-regex': 'warn',
158
+ 'sonarjs/todo-tag': 'off',
159
+ },
160
+ },
161
+ ];
162
+
163
+ /** @type {import('eslint').Linter.Config[]} */
164
+ export const jest = [
165
+ ...fixupConfigRules(
166
+ compat.extends('plugin:jest/recommended').map((config) => ({
167
+ ...config,
168
+ files: ['**/jest.*js', '**/*.spec.{js,jsx}'],
169
+ languageOptions: {
170
+ globals: {
171
+ ...globals.jest,
172
+ ...globals.node,
173
+ },
174
+ },
175
+ })),
176
+ ),
177
+ ];
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/prefer-module */
2
1
  module.exports = {
3
2
  configs: {
4
3
  base: require('./configs/base'),
package/jest.config.js CHANGED
@@ -1,5 +1,3 @@
1
- /* eslint-disable unicorn/prefer-module */
2
1
  module.exports = {
3
- // eslint-disable-next-line import/extensions
4
2
  displayName: require('./package.json').name,
5
3
  };
package/package.json CHANGED
@@ -1,37 +1,45 @@
1
1
  {
2
2
  "name": "@autoguru/eslint-plugin",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "description": "AutoGuru's shareable eslint config and custom plugins",
5
5
  "homepage": "https://github.com/autoguru-au/octane/tree/master/packages/eslint-plugin#readme",
6
6
  "repository": "https://github.com/autoguru-au/octane/tree/master/packages/eslint-plugin",
7
7
  "license": "MIT",
8
8
  "main": "index.js",
9
+ "exports": {
10
+ "./config": {
11
+ "import": "./flat-config.mjs"
12
+ }
13
+ },
9
14
  "scripts": {
10
15
  "build": "echo \"no op\""
11
16
  },
12
17
  "dependencies": {
13
- "@typescript-eslint/eslint-plugin": "^4.26.0",
14
- "@typescript-eslint/parser": "^4.26.0",
15
- "eslint-config-prettier": "^8.3.0",
16
- "eslint-import-resolver-typescript": "^2.4.0",
17
- "eslint-plugin-import": "^2.23.4",
18
- "eslint-plugin-jsx-a11y": "^6.4.1",
19
- "eslint-plugin-promise": "^5.1.0",
20
- "eslint-plugin-react": "^7.24.0",
21
- "eslint-plugin-react-hooks": "^4.2.0",
22
- "eslint-plugin-sonarjs": "^0.19.0",
23
- "eslint-plugin-unicorn": "^33.0.1"
18
+ "@eslint/compat": "^1.2.6",
19
+ "@eslint/eslintrc": "^3.2.0",
20
+ "@eslint/js": "^9.20.0",
21
+ "@typescript-eslint/parser": "^8.24.1",
22
+ "eslint-config-prettier": "^10.0.1",
23
+ "eslint-import-resolver-typescript": "^3.8.2",
24
+ "eslint-plugin-import": "^2.31.0",
25
+ "eslint-plugin-jest": "^26.9.0",
26
+ "eslint-plugin-jsx-a11y": "^6.10.2",
27
+ "eslint-plugin-promise": "^7.2.1",
28
+ "eslint-plugin-react": "^7.37.4",
29
+ "eslint-plugin-react-hooks": "^5.1.0",
30
+ "eslint-plugin-sonarjs": "^3.0.2",
31
+ "eslint-plugin-unicorn": "^56.0.0",
32
+ "globals": "^15.15.0",
33
+ "typescript-eslint": "^8.24.1"
24
34
  },
25
35
  "peerDependencies": {
26
- "eslint": ">=7",
27
- "eslint-plugin-jest": ">=24"
36
+ "eslint": ">=7"
28
37
  },
29
38
  "publishConfig": {
30
39
  "access": "public"
31
40
  },
32
41
  "devDependencies": {
33
- "@types/eslint": "^7.2.13",
34
- "eslint": "^7.28.0",
35
- "eslint-plugin-jest": "^24.3.6"
42
+ "@types/eslint": "^9.6.1",
43
+ "eslint": "^9.20.1"
36
44
  }
37
45
  }
package/readme.md CHANGED
@@ -7,7 +7,29 @@ yarn add --dev @autoguru/eslint-plugin \
7
7
  eslint
8
8
  ```
9
9
 
10
- then in your `package.json` or `.eslintrc.yml` file:
10
+ Modern eslint requires the flat config format and the package exports config for
11
+ use with eslint.config.m/js.
12
+
13
+ ```js
14
+ import { base, react, typescript } from '@autoguru/eslint-plugin/config';
15
+
16
+ /** @type {import('eslint').Linter.Config[]} */
17
+ export default [
18
+ ...base,
19
+ ...typescript,
20
+ ...react,
21
+ {
22
+ rules: {
23
+ // custom rules as normal
24
+ },
25
+ },
26
+ ];
27
+ ```
28
+
29
+ ### Legacy eslint
30
+
31
+ For versions prior to 9, configure it by extending your `package.json` or
32
+ `.eslintrc.yml` file:
11
33
 
12
34
  ```yml
13
35
  extends:
@@ -16,3 +38,7 @@ extends:
16
38
  - 'plugin:@autoguru/react' // react and react hook checks
17
39
  - 'plugin:@autoguru/jest' // jest, so we test better
18
40
  ```
41
+
42
+ If there are incompabitiblities with a version of eslint plugin coming from the
43
+ @autoguru/eslint-plugin, you may need to pin an older version by using package
44
+ file resolutions.