@autoguru/eslint-plugin 1.6.0 → 2.0.1

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,40 +1,60 @@
1
1
  # @autoguru/eslint-plugin
2
2
 
3
+ ## 2.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 31133ad: Migrate monorepo tooling from Yarn to Bun
8
+ - Replace `find-yarn-workspace-root` with a built-in workspace root resolver
9
+ in gdu
10
+ - Update Yarn CLI references to Bun across documentation and build scripts
11
+ - Add `.macro` extension to ESLint import resolution config
12
+ - Update browserslist browser version snapshot
13
+
14
+ ## 2.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - 0f9d788: Migrates to Eslint 9, maintaining the commonly needed rules in config
19
+ and extracting project-specific rules. The plugin continues to export the
20
+ legacy configs in common-js, the modern configs are exported from
21
+ `@autoguru/eslint-plugin/config`.
22
+
3
23
  ## 1.6.0
4
24
 
5
25
  ### Minor Changes
6
26
 
7
- - 8297630: Dependency upgrades
27
+ - 8297630: Dependency upgrades
8
28
 
9
29
  ## 1.5.0
10
30
 
11
31
  ### Minor Changes
12
32
 
13
- - 05747b1: Added nx workspaces
33
+ - 05747b1: Added nx workspaces
14
34
 
15
35
  ## 1.4.0
16
36
 
17
37
  ### Minor Changes
18
38
 
19
- - de55945: Adds sonarjs eslint rules to AutoGuru typescript eslint
39
+ - de55945: Adds sonarjs eslint rules to AutoGuru typescript eslint
20
40
 
21
41
  ## 1.3.2
22
42
 
23
43
  ### Patch Changes
24
44
 
25
- - ae9cd96: Removes next eslint
45
+ - ae9cd96: Removes next eslint
26
46
 
27
47
  ## 1.3.1
28
48
 
29
49
  ### Patch Changes
30
50
 
31
- - ebee6d4: GDU: Adds CSP rules @autoguru/eslint-plugin: Adds nextjs defaults
51
+ - ebee6d4: GDU: Adds CSP rules @autoguru/eslint-plugin: Adds nextjs defaults
32
52
 
33
53
  ## 1.3.0
34
54
 
35
55
  ### Minor Changes
36
56
 
37
- - d80a10b: Unicorn eslint rules: Upgraded to v33
57
+ - d80a10b: Unicorn eslint rules: Upgraded to v33
38
58
 
39
59
  Prettier: Upgrades to v2.3
40
60
 
@@ -42,47 +62,47 @@
42
62
 
43
63
  ### Minor Changes
44
64
 
45
- - df57e1a: Upgrades eslint packages
65
+ - df57e1a: Upgrades eslint packages
46
66
 
47
67
  ## 1.1.5
48
68
 
49
69
  ### Patch Changes
50
70
 
51
- - 3827266: Prettier just has itself (no more /react)
71
+ - 3827266: Prettier just has itself (no more /react)
52
72
 
53
73
  ## 1.1.4
54
74
 
55
75
  ### Patch Changes
56
76
 
57
- - 919e4a0: Upgraded all dev and prod deps
77
+ - 919e4a0: Upgraded all dev and prod deps
58
78
 
59
79
  ## 1.1.3
60
80
 
61
81
  ### Patch Changes
62
82
 
63
- - f1dd447: The react-in-scope rule is now mute
83
+ - f1dd447: The react-in-scope rule is now mute
64
84
 
65
85
  ## 1.1.2
66
86
 
67
87
  ### Patch Changes
68
88
 
69
- - 4260eb3: Bumps all deps
89
+ - 4260eb3: Bumps all deps
70
90
 
71
91
  ## 1.1.1
72
92
 
73
93
  ### Patch Changes
74
94
 
75
- - 5567db1: Fixes some eslint rules breaking our things
95
+ - 5567db1: Fixes some eslint rules breaking our things
76
96
 
77
97
  ## 1.1.0
78
98
 
79
99
  ### Minor Changes
80
100
 
81
- - bf0d849: Smaller more simple eslint config. Using less plugins, to help
82
- improve eslint runs and also more granular control.
101
+ - bf0d849: Smaller more simple eslint config. Using less plugins, to help
102
+ improve eslint runs and also more granular control.
83
103
 
84
104
  ## 1.0.85
85
105
 
86
106
  ### Patch Changes
87
107
 
88
- - b0d77f1: Mass upgrade of dependencies
108
+ - 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
 
@@ -35,6 +34,7 @@ module.exports = {
35
34
  graphql: 'always',
36
35
  treat: 'always',
37
36
  scss: 'always',
37
+ macro: 'always',
38
38
  },
39
39
  ],
40
40
  'import/no-duplicates': 'error',
@@ -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,178 @@
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
+ macro: 'always',
60
+ },
61
+ ],
62
+ 'import/no-duplicates': 'error',
63
+ },
64
+ },
65
+ ];
66
+
67
+ // Eslint base config including import
68
+ /** @type {import('eslint').Linter.Config[]} */
69
+ export const base = [
70
+ js.configs.recommended,
71
+ ...imports,
72
+ ...fixupConfigRules(
73
+ compat.extends(
74
+ 'plugin:unicorn/recommended',
75
+ 'plugin:promise/recommended',
76
+ 'prettier',
77
+ ),
78
+ ),
79
+ {
80
+ languageOptions: {
81
+ globals: globals.browser,
82
+ },
83
+ rules: {
84
+ 'no-sparse-arrays': 'warn',
85
+ 'unicorn/filename-case': 'off',
86
+ 'unicorn/prevent-abbreviations': 'off',
87
+ 'unicorn/no-null': 'off',
88
+ 'unicorn/no-reduce': 'off',
89
+ 'unicorn/no-array-reduce': 'off',
90
+ 'unicorn/no-array-for-each': 'off',
91
+ 'unicorn/no-array-push-push': 'off',
92
+ 'unicorn/prefer-global-this': 'off',
93
+ 'unicorn/prefer-spread': 'warn',
94
+ },
95
+ },
96
+ ];
97
+
98
+ // Eslint react plugins, settings and rules
99
+ /** @type {import('eslint').Linter.Config[]} */
100
+ export const react = [
101
+ ...fixupConfigRules(
102
+ compat.extends(
103
+ 'plugin:react/recommended',
104
+ 'plugin:react-hooks/recommended',
105
+ ),
106
+ ),
107
+ {
108
+ plugins: {
109
+ react: fixupPluginRules(reactEslint),
110
+ 'react-hooks': fixupPluginRules(reactHooks),
111
+ 'jsx-a11y': jsxA11Y,
112
+ },
113
+ settings: {
114
+ react: {
115
+ version: 'detect',
116
+ },
117
+ },
118
+ rules: {
119
+ 'react/no-array-index-key': 'warn',
120
+ 'react/prop-types': 'off',
121
+ 'react/display-name': 'off',
122
+ },
123
+ },
124
+ ];
125
+
126
+ // TypeScript plugins, and SonarJS plugin settings and rules
127
+ /** @type {import('eslint').Linter.Config[]} */
128
+ export const typescript = [
129
+ ...tseslint.configs.recommended,
130
+ ...fixupConfigRules(
131
+ compat.extends(
132
+ 'plugin:import/typescript',
133
+ 'plugin:sonarjs/recommended-legacy',
134
+ ),
135
+ ),
136
+ {
137
+ plugins: {
138
+ sonarjs: fixupPluginRules(sonarjs),
139
+ },
140
+ languageOptions: {
141
+ parser: tsParser,
142
+ ecmaVersion: 2020,
143
+ sourceType: 'module',
144
+ parserOptions: {
145
+ ecmaFeatures: {
146
+ jsx: true,
147
+ },
148
+ },
149
+ },
150
+ settings: {
151
+ 'import/resolver': {
152
+ typescript: {},
153
+ },
154
+ },
155
+ rules: {
156
+ 'sonarjs/no-duplicate-string': 'warn',
157
+ 'sonarjs/no-nested-template-literals': 'warn',
158
+ 'sonarjs/slow-regex': 'warn',
159
+ 'sonarjs/todo-tag': 'off',
160
+ },
161
+ },
162
+ ];
163
+
164
+ /** @type {import('eslint').Linter.Config[]} */
165
+ export const jest = [
166
+ ...fixupConfigRules(
167
+ compat.extends('plugin:jest/recommended').map((config) => ({
168
+ ...config,
169
+ files: ['**/jest.*js', '**/*.spec.{js,jsx}'],
170
+ languageOptions: {
171
+ globals: {
172
+ ...globals.jest,
173
+ ...globals.node,
174
+ },
175
+ },
176
+ })),
177
+ ),
178
+ ];
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,46 @@
1
1
  {
2
2
  "name": "@autoguru/eslint-plugin",
3
- "version": "1.6.0",
3
+ "version": "2.0.1",
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": "^7.8.0",
14
- "@typescript-eslint/parser": "^7.8.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
- "access": "public"
39
+ "access": "public",
40
+ "provenance": true
31
41
  },
32
42
  "devDependencies": {
33
- "@types/eslint": "^7.2.13",
34
- "eslint": "^7.28.0",
35
- "eslint-plugin-jest": "^24.3.6"
43
+ "@types/eslint": "^9.6.1",
44
+ "eslint": "^9.20.1"
36
45
  }
37
46
  }
package/readme.md CHANGED
@@ -3,11 +3,33 @@
3
3
  ## Usage
4
4
 
5
5
  ```sh
6
- yarn add --dev @autoguru/eslint-plugin \
6
+ bun 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.