@australiangreens/eslint-plugin-ag-internal 0.2.0 → 0.2.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/README.md +102 -1
- package/dist/configs/javascript.js +1 -0
- package/dist/configs/react.js +1 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,2 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# eslint-plugin-ag-internal
|
|
2
2
|
|
|
3
|
+
A collection of eslint rules we use across our JS and TS applications.
|
|
4
|
+
|
|
5
|
+
This is intended to strictly be an ESM-only package for eslint 9+ with the flat
|
|
6
|
+
config. No attempt has been made for backwards compatibility.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
There is a single peer dependency `eslint` version 9.26.0 or above.
|
|
11
|
+
|
|
12
|
+
In a simple React application with a standard structure the minimal
|
|
13
|
+
`eslint.config.js` file will look like:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import agLintPlugin from '@australiangreens/eslint-plugin-ag-internal';
|
|
17
|
+
|
|
18
|
+
export default agLintPlugin.configs.recommendedReact;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For more control over the ignored files etc, you may need something more like:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import agLintPlugin from '@australiangreens/eslint-plugin-ag-internal';
|
|
25
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
26
|
+
import globals from 'globals';
|
|
27
|
+
|
|
28
|
+
export default defineConfig([
|
|
29
|
+
globalIgnores(['**/node_modules', '**/dist', '**/coverage']),
|
|
30
|
+
{
|
|
31
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
32
|
+
languageOptions: {
|
|
33
|
+
globals: {
|
|
34
|
+
...globals.browser,
|
|
35
|
+
...globals.jest,
|
|
36
|
+
...globals.vitest,
|
|
37
|
+
...globals.node,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
agLintPlugin.configs.recommendedReact,
|
|
42
|
+
]);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Configs
|
|
46
|
+
|
|
47
|
+
There are 4 configs: `recommended`, `recommendedReact`, `recommendJsOnly` and
|
|
48
|
+
`recommendedReactJsOnly`. Since we primarily use typescript, typically we'll
|
|
49
|
+
only be using the first 2.
|
|
50
|
+
|
|
51
|
+
In all configs the rules are enabled as _errors_ with the exception of ones in
|
|
52
|
+
the `react-you-might-not-need-an-effect/` namespace, which are currently only
|
|
53
|
+
_warnings_. This may be changed in the future.
|
|
54
|
+
|
|
55
|
+
### recommendedJsOnly
|
|
56
|
+
|
|
57
|
+
- [eslint js plugin](https://www.npmjs.com/package/@eslint/js)'s recommended
|
|
58
|
+
rules with some changes to `radix` and `no-plusplus`.
|
|
59
|
+
|
|
60
|
+
- [import plugin](https://www.npmjs.com/package/eslint-plugin-import-esm)'s
|
|
61
|
+
recommended rules with the addition of 2 strict rules.
|
|
62
|
+
|
|
63
|
+
- [import](https://www.npmjs.com/package/eslint-plugin-import-esm)
|
|
64
|
+
typescript rules. **TODO: Move to typescript config**.
|
|
65
|
+
|
|
66
|
+
### recommended
|
|
67
|
+
|
|
68
|
+
All the rules from recommendedJsOnly with the addition of the following:
|
|
69
|
+
|
|
70
|
+
- [typescript-eslint plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)'s
|
|
71
|
+
recommended rules with some small tweaks.
|
|
72
|
+
|
|
73
|
+
- [tsdoc plugin](https://www.npmjs.com/package/eslint-plugin-tsdoc)'s single
|
|
74
|
+
`tsdoc/syntax` rule enabled as _error_.
|
|
75
|
+
|
|
76
|
+
## recommendedReactJsOnly
|
|
77
|
+
|
|
78
|
+
recommendedJsOnly with the addition of the following:
|
|
79
|
+
|
|
80
|
+
- [jsx-a11y plugin](https://www.npmjs.com/package/@types/eslint-plugin-jsx-a11y)'s
|
|
81
|
+
strict rules with some extras that won't be enabled by default until a
|
|
82
|
+
later version of the plugin.
|
|
83
|
+
|
|
84
|
+
- [react plugin](https://www.npmjs.com/package/eslint-plugin-react)'s
|
|
85
|
+
recommended rules with an increase in strictness of the
|
|
86
|
+
`react/destructuring-assignment` rule.
|
|
87
|
+
|
|
88
|
+
- [react plugin](https://www.npmjs.com/package/eslint-plugin-react)'s
|
|
89
|
+
jsx-runtime rules.
|
|
90
|
+
|
|
91
|
+
- [react-hooks plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks)'s
|
|
92
|
+
recommended-latest rules
|
|
93
|
+
|
|
94
|
+
- [react-refresh plugin](https://www.npmjs.com/package/eslint-plugin-react-refresh)'s
|
|
95
|
+
single rule.
|
|
96
|
+
|
|
97
|
+
- [react-you-might-not-need-an-effect](https://www.npmjs.com/package/eslint-plugin-react-you-might-not-need-an-effect)'s
|
|
98
|
+
recommended rules (as warnings, not errors).
|
|
99
|
+
|
|
100
|
+
## recommendedReact
|
|
101
|
+
|
|
102
|
+
All the rules in recommendedReactJsOnly with the new ones that recommended
|
|
103
|
+
brings.
|
package/dist/configs/react.js
CHANGED
|
@@ -33,7 +33,7 @@ const config = [
|
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
|
-
// The plugin provides 2
|
|
36
|
+
// The plugin provides 2 rules
|
|
37
37
|
reactHooksPlugin.configs['recommended-latest'],
|
|
38
38
|
{
|
|
39
39
|
name: `${pluginName()}/react-hooks`,
|
|
@@ -44,13 +44,6 @@ const config = [
|
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
reactRefreshPlugin.configs.recommended,
|
|
47
|
-
{
|
|
48
|
-
name: `${pluginName()}/react-refresh`,
|
|
49
|
-
rules: {
|
|
50
|
-
// [LIST-974] Disabled for now until we fix the issues it raises
|
|
51
|
-
'react-refresh/only-export-components': 'off',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
47
|
// All recommended rules in eslint-plugin-react-you-might-not-need-an-effect
|
|
55
48
|
// are enabled as warnings, unlike other plugins, we do not override this
|
|
56
49
|
// for now
|