@greenharness/greenrack-eslint-config 0.0.0-reserved → 7.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/LICENSE +21 -0
- package/README.md +119 -1
- package/index.d.ts +8 -0
- package/package.json +56 -4
- package/src/index.js +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Frederic Rousseau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
1
|
# @greenharness/greenrack-eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shareable ESLint flat config for the greenrack stack — the policies CLAUDE.md and
|
|
4
|
+
agent memory can only suggest, wired into the linter so every consumer repo
|
|
5
|
+
gates them at commit time (via amont's built-in `pre-commit-lint-js`, which
|
|
6
|
+
activates on the presence of a root ESLint config) and in CI.
|
|
7
|
+
|
|
8
|
+
Requires ESLint 9 or 10 (flat config). It keeps only the design-system and
|
|
9
|
+
UI-library policy, as `react`. The general conventions (`base`, `effect`,
|
|
10
|
+
`tests`) and the decided-rule bridge (`adrLint`) come from
|
|
11
|
+
[`@aval-adr/eslint-config`](https://www.npmjs.com/package/@aval-adr/eslint-config),
|
|
12
|
+
which this package extends and declares as a peer: install both.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
pnpm add -D @greenharness/greenrack-eslint-config @aval-adr/eslint-config
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
// eslint.config.js (repo root — amont only detects a ROOT config)
|
|
22
|
+
import {react} from '@greenharness/greenrack-eslint-config'
|
|
23
|
+
import {effect, tests} from '@aval-adr/eslint-config'
|
|
24
|
+
|
|
25
|
+
export default [
|
|
26
|
+
{ignores: ['**/dist/**', '**/build/**']},
|
|
27
|
+
...react,
|
|
28
|
+
...tests,
|
|
29
|
+
// Server-only packages in a monorepo can scope the effect preset:
|
|
30
|
+
...effect.map((c) => ({...c, files: ['apps/api/**/*.ts']})),
|
|
31
|
+
]
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Presets
|
|
35
|
+
|
|
36
|
+
| Preset | From | Composes | For |
|
|
37
|
+
| -------- | --------------------------------------- | -------------------------------------------------------------------- | --------------------------------------- |
|
|
38
|
+
| `react` | `@greenharness/greenrack-eslint-config` | aval `base` + classic react-hooks + the greenrack plugin + UI policy | RSD / `@greenharness/greenrack-ui` apps |
|
|
39
|
+
| `base` | `@aval-adr/eslint-config` | `@eslint/js` + `typescript-eslint` recommended, prettier interop | every TypeScript package |
|
|
40
|
+
| `effect` | `@aval-adr/eslint-config` | `base` + `@effect` plugin + server-stack policy | Effect services |
|
|
41
|
+
| `tests` | `@aval-adr/eslint-config` | accessibility-first selectors (self-scoped to test/e2e files) | any repo with tests |
|
|
42
|
+
|
|
43
|
+
`react` reports its import bans as `greenrack/no-restricted-imports`, apart from
|
|
44
|
+
`effect`'s `@typescript-eslint/no-restricted-imports` and adr-lint's
|
|
45
|
+
`adr-lint/no-restricted-imports`, so composing them keeps every ban: none of
|
|
46
|
+
the three overrides another.
|
|
47
|
+
|
|
48
|
+
## What the policy enforces
|
|
49
|
+
|
|
50
|
+
- **`react`**: UI primitives come from `@greenharness/greenrack-ui` only. react-aria,
|
|
51
|
+
Spectrum, MUI, Radix, Chakra, headlessui, antd and `@frontjutsu/ui` are
|
|
52
|
+
banned with a message that says where to add a missing component. Rich
|
|
53
|
+
text goes through `@fredericrous/lexical-multi`, never raw `lexical`. It
|
|
54
|
+
also carries everything in `@greenharness/greenrack-eslint-plugin`: html.\* elements,
|
|
55
|
+
deep token imports, token values and the form kit.
|
|
56
|
+
- `effect` and `tests` are documented with `@aval-adr/eslint-config`.
|
|
57
|
+
|
|
58
|
+
Severity is the one gating line: `error` gates at commit and CI, `warn`
|
|
59
|
+
informs everywhere. Don't add `--max-warnings=0` — promote a rule to
|
|
60
|
+
`error` here instead if it earns gating.
|
|
61
|
+
|
|
62
|
+
### Adopting 3.0 with existing debt
|
|
63
|
+
|
|
64
|
+
3.0 promotes `greenrack/no-raw-design-values` to `error` and adds
|
|
65
|
+
`greenrack/no-raw-breakpoint-query`. A repo that already carries raw values keeps
|
|
66
|
+
the gate for every **new** file and ratchets the old ones down with an
|
|
67
|
+
explicit file list — never a glob, never `--max-warnings`:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// eslint.greenrack-baseline.js — delete a line when its file is migrated. Never add one.
|
|
71
|
+
export const RAW_VALUES_BASELINE = [
|
|
72
|
+
'app/routes/legacy-dashboard.tsx',
|
|
73
|
+
'app/components/OldChart/OldChart.tsx',
|
|
74
|
+
]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
// eslint.config.js — after the presets, so last-wins downgrades only these
|
|
79
|
+
import {RAW_VALUES_BASELINE} from './eslint.greenrack-baseline.js'
|
|
80
|
+
export default [
|
|
81
|
+
...react,
|
|
82
|
+
{files: RAW_VALUES_BASELINE, rules: {'greenrack/no-raw-design-values': 'warn'}},
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Most findings carry a suggestion; the ESLint API can apply them in bulk
|
|
87
|
+
(`message.suggestions[0].fix`). What is left is the handful that need a
|
|
88
|
+
human choice — an off-palette color, an off-scale spacing.
|
|
89
|
+
|
|
90
|
+
## Escape hatches
|
|
91
|
+
|
|
92
|
+
Flat config is last-wins — scope an override after the preset:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
...react,
|
|
96
|
+
{
|
|
97
|
+
// The one file allowed to import the raw engine reset:
|
|
98
|
+
files: ['packages/editor/src/usePageNode.ts'],
|
|
99
|
+
rules: {'greenrack/no-restricted-imports': 'off'},
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## adr-lint rules (opt-in)
|
|
104
|
+
|
|
105
|
+
`adrLint` and `adrLintTyped` add the decided code rules a linter matches
|
|
106
|
+
exactly. Import them from `@aval-adr/eslint-config` and put them last. Their
|
|
107
|
+
bans have their own rule id, so no `stack` option is needed (6.0 drops it):
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import {react} from '@greenharness/greenrack-eslint-config'
|
|
111
|
+
import {adrLint} from '@aval-adr/eslint-config'
|
|
112
|
+
|
|
113
|
+
export default [...react, ...adrLint()]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Migrating from 5.x
|
|
117
|
+
|
|
118
|
+
- Add `@aval-adr/eslint-config` (`^0.16.0`) beside this package.
|
|
119
|
+
- Import `base`, `effect`, `tests` and `adrLint` from it; keep `react` from here.
|
|
120
|
+
- Drop `stack` from an `adrLint` call.
|
|
121
|
+
- An override of `no-restricted-imports` for the UI bans becomes `greenrack/no-restricted-imports`.
|
package/index.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greenharness/greenrack-eslint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"description": "Shareable ESLint flat config for the greenrack design system: the design-system rules and UI-library policy for React apps, on top of @aval-adr/eslint-config.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"eslint",
|
|
9
|
+
"eslintconfig",
|
|
10
|
+
"eslint-config",
|
|
11
|
+
"react-strict-dom",
|
|
12
|
+
"design-system"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/greenharness/greenrack",
|
|
17
|
+
"directory": "packages/eslint-config"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/greenharness/greenrack",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/greenharness/greenrack/issues"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"src",
|
|
28
|
+
"index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"main": "src/index.js",
|
|
31
|
+
"types": "index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./index.d.ts",
|
|
35
|
+
"import": "./src/index.js",
|
|
36
|
+
"default": "./src/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@aval-adr/eslint-config": ">=0.16.0 <1",
|
|
44
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
48
|
+
"typescript-eslint": "^8.56.0",
|
|
49
|
+
"@greenharness/greenrack-eslint-plugin": "^7.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@aval-adr/eslint-config": "^0.16.0",
|
|
53
|
+
"eslint": "^9.20.0",
|
|
54
|
+
"typescript": "^5.7.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
}
|
|
59
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
2
|
+
import greenrack from '@greenharness/greenrack-eslint-plugin'
|
|
3
|
+
import {base} from '@aval-adr/eslint-config'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The greenrack design-system and UI-library policy, on top of the harness's
|
|
7
|
+
* `base` from @aval-adr/eslint-config. `base`, `effect`, `tests` and
|
|
8
|
+
* `adrLint` come from @aval-adr/eslint-config directly; this package keeps
|
|
9
|
+
* only `react`, which carries what only the design system knows: the greenrack
|
|
10
|
+
* plugin rules and the foreign-UI and Lexical import bans.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const FOREIGN_UI_MESSAGE =
|
|
14
|
+
'UI primitives come from @greenharness/greenrack-ui only. If the component you need is missing, add it to greenrack instead of reaching for another library — `npx greenrack list` shows what exists.'
|
|
15
|
+
|
|
16
|
+
const LEXICAL_MESSAGE =
|
|
17
|
+
'Rich text goes through @fredericrous/lexical-multi at the app layer, never raw Lexical — the wrapper carries the multi-editor state, native support, and edit-state accessibility.'
|
|
18
|
+
|
|
19
|
+
const FOREIGN_UI_PATTERN = {
|
|
20
|
+
allowTypeImports: true,
|
|
21
|
+
group: [
|
|
22
|
+
'react-aria',
|
|
23
|
+
'react-aria-components',
|
|
24
|
+
'@react-aria/*',
|
|
25
|
+
'@adobe/react-spectrum',
|
|
26
|
+
'@react-spectrum/*',
|
|
27
|
+
'@mui/*',
|
|
28
|
+
'@material-ui/*',
|
|
29
|
+
'@radix-ui/*',
|
|
30
|
+
'@chakra-ui/*',
|
|
31
|
+
'@headlessui/*',
|
|
32
|
+
'antd',
|
|
33
|
+
'antd/*',
|
|
34
|
+
'@frontjutsu/ui',
|
|
35
|
+
'@frontjutsu/ui/*',
|
|
36
|
+
],
|
|
37
|
+
message: FOREIGN_UI_MESSAGE,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const LEXICAL_PATTERN = {
|
|
41
|
+
allowTypeImports: true,
|
|
42
|
+
group: ['lexical', '@lexical/*'],
|
|
43
|
+
message: LEXICAL_MESSAGE,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** @type {import('eslint').Linter.Config[]} */
|
|
47
|
+
export const react = [
|
|
48
|
+
...base,
|
|
49
|
+
// Classic hooks correctness only. react-hooks v7's flat.recommended also
|
|
50
|
+
// ships the React Compiler-era rules (refs, set-state-in-effect,
|
|
51
|
+
// immutability, …) at error — adopting those is a per-repo migration
|
|
52
|
+
// (greenrack deferred ~27 sites, website-builder ~53), not a
|
|
53
|
+
// default gate. A repo that adopts the compiler opts in on top.
|
|
54
|
+
{
|
|
55
|
+
name: 'greenrack-config/react-hooks-classic',
|
|
56
|
+
plugins: {'react-hooks': reactHooks},
|
|
57
|
+
rules: {
|
|
58
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
59
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
greenrack.configs.recommended,
|
|
63
|
+
{
|
|
64
|
+
name: 'greenrack-config/react-policy',
|
|
65
|
+
rules: {
|
|
66
|
+
// The typescript-eslint rule, not the core one, for `allowTypeImports`.
|
|
67
|
+
// Banning a module by name also catches `import type {X} from 'lexical'`,
|
|
68
|
+
// and a type import erases at compile time: it reaches no runtime module,
|
|
69
|
+
// so it bypasses nothing these bans protect. kb-vision hit exactly that —
|
|
70
|
+
// it uses the wrapper correctly and needed one type the wrapper does not
|
|
71
|
+
// re-export — and had to carry a local override to say so.
|
|
72
|
+
'no-restricted-imports': 'off',
|
|
73
|
+
'greenrack/no-restricted-imports': [
|
|
74
|
+
'error',
|
|
75
|
+
{
|
|
76
|
+
patterns: [FOREIGN_UI_PATTERN, LEXICAL_PATTERN],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
export default {react}
|