@atom63/eslint-plugin 0.0.0-stage → 0.1.0-beta.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 +27 -0
- package/README.md +75 -2
- package/bin/atom63-lint-baseline.mjs +34 -0
- package/generated/rule-data.json +5360 -0
- package/package.json +41 -3
- package/src/core/craft.mjs +450 -0
- package/src/core/escapes.mjs +149 -0
- package/src/core/warnings.mjs +101 -0
- package/src/index.mjs +90 -0
- package/src/lib/data.mjs +16 -0
- package/src/lib/define.mjs +109 -0
- package/src/lib/scans.mjs +10 -0
- package/src/rules/craft.mjs +76 -0
- package/src/rules/escapes.mjs +70 -0
- package/src/rules/no-deprecated-value.mjs +71 -0
- package/src/rules/warnings.mjs +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 You Zhang (ATOM63)
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The MIT license above covers the code and documentation in this repository. It does not grant
|
|
26
|
+
any right to use the ATOM63 name, the ATOM63 logo or other ATOM63 brand marks, including the
|
|
27
|
+
artwork in packages/brand. All rights to them are reserved.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @atom63/eslint-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ESLint rules that keep screen code on the Atom63 design system. A rule's message says what to use
|
|
4
|
+
instead, so a person or a coding agent can fix it in the same pass.
|
|
5
|
+
|
|
6
|
+
The rules report what the design system's own checks find: `check:craft` and the replication
|
|
7
|
+
benchmark call the same functions (`src/core`), so a consumer's lint and the benchmark's escape
|
|
8
|
+
count agree.
|
|
9
|
+
|
|
10
|
+
Published on npm under the `beta` tag: `pnpm add -D @atom63/eslint-plugin@beta`.
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
// eslint.config.js
|
|
14
|
+
import atom63 from '@atom63/eslint-plugin'
|
|
15
|
+
|
|
16
|
+
export default [...atom63.configs.recommended]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Oxlint loads it as a JS plugin. There the rules are named `@atom63/<rule>`, and Oxlint takes no
|
|
20
|
+
shareable config from a plugin, so list the rules you want:
|
|
21
|
+
|
|
22
|
+
```json
|
|
23
|
+
{
|
|
24
|
+
"jsPlugins": ["@atom63/eslint-plugin"],
|
|
25
|
+
"rules": { "@atom63/no-raw-control": "warn", "@atom63/no-deprecated-value": "error" }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`test/oxlint.test.mjs` runs both linters over the same fixture and expects the same findings.
|
|
30
|
+
|
|
31
|
+
## Configs
|
|
32
|
+
|
|
33
|
+
- `recommended`: the craft and escape rules as errors, the two Button warnings as warnings. Pair
|
|
34
|
+
it with a baseline so an existing codebase passes today and can only get better.
|
|
35
|
+
- `strict`: every rule as an error.
|
|
36
|
+
- `migrate`: every rule as a warning, for a first look at a codebase before any baseline exists.
|
|
37
|
+
|
|
38
|
+
Each config is an array: the craft rules apply to `js/jsx/mjs/ts/tsx/mts` files, the JSX rules to
|
|
39
|
+
`jsx/tsx`.
|
|
40
|
+
|
|
41
|
+
## Rules
|
|
42
|
+
|
|
43
|
+
| Rule | Reports | Same as |
|
|
44
|
+
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
|
|
45
|
+
| `no-raw-control` | An interactive HTML element (`<button>`, `<a>`, `<input>`, …) where the system has a component. An element passed as a component's `render` prop passes. | replication `raw-control` |
|
|
46
|
+
| `no-component-override` | A `className` on an Atom63 component that repaints, resizes or reshapes what its recipe owns. | replication `component-override` |
|
|
47
|
+
| `no-reach-in-selector` | A Tailwind arbitrary variant (`[&_svg]:`, `data-[…]:`) that styles a component's insides from outside. | replication `arbitrary-selector` |
|
|
48
|
+
| `no-raw-value` | An arbitrary value (`p-[13px]`, `bg-[#123]`) that is not a token. | replication `arbitrary-value` |
|
|
49
|
+
| `no-inline-style` | A `style` prop. | replication `inline-style` |
|
|
50
|
+
| `raw-color` | A literal colour or colour keyword. | `check:craft` |
|
|
51
|
+
| `physical-properties` | `left`/`right` properties and utilities where a logical one exists. | `check:craft` |
|
|
52
|
+
| `focus-visible` | A focus style on `:focus` instead of `:focus-visible`. | `check:craft` |
|
|
53
|
+
| `focus-ring-outline` | A focus ring drawn with `box-shadow` or `ring-*`. | `check:craft` |
|
|
54
|
+
| `mode-branch` | Code that branches on light or dark mode. | `check:craft` |
|
|
55
|
+
| `unknown-token` | An `--a63-*` name the token manifest does not have. | `check:craft` |
|
|
56
|
+
| `token-role` | A text token used as a fill, or a fill token as text. | `check:craft` |
|
|
57
|
+
| `internal-token` | An internal token read or written outside the design system; the message names the nearest public one. | `check:craft` |
|
|
58
|
+
| `no-deprecated-value` | A contract axis value that is a deprecated alias (`size="default"` → `size="md"`). Autofixes. | contracts `deprecatedAliases` |
|
|
59
|
+
| `single-primary` | More than one `variant="primary"` Button in a file. | vibe `multiple-primary` |
|
|
60
|
+
| `ghost-needs-tone` | A `variant="ghost"` Button with no `tone`. | vibe `ghost-without-tone` |
|
|
61
|
+
|
|
62
|
+
## Baseline
|
|
63
|
+
|
|
64
|
+
Every rule takes `{ baseline: { "<path from cwd>": <count> } }`. A file at or under its count reports
|
|
65
|
+
nothing; a file over it reports every finding. `atom63-lint-baseline` writes the object from ESLint
|
|
66
|
+
JSON output, so a codebase can turn the rules on and only shrink the numbers:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
eslint -f json . | atom63-lint-baseline > atom63-baseline.json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Rule data
|
|
73
|
+
|
|
74
|
+
`generated/rule-data.json` holds the token names, roles, tiers and deprecated values the rules read.
|
|
75
|
+
`pnpm --filter @atom63/eslint-plugin generate:data` rebuilds it from the token manifest and the
|
|
76
|
+
contracts; CI runs `check:data`.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Writes a per-file baseline for the atom63 rules from ESLint's JSON output,
|
|
4
|
+
* so an existing codebase can adopt the rules and pay its findings down:
|
|
5
|
+
*
|
|
6
|
+
* eslint -f json . | atom63-lint-baseline > atom63-baseline.json
|
|
7
|
+
*
|
|
8
|
+
* The output maps each rule to `{ file: count }`, with files relative to the
|
|
9
|
+
* current directory. Pass a rule's entry as its `baseline` option:
|
|
10
|
+
*
|
|
11
|
+
* import baseline from './atom63-baseline.json' with { type: 'json' }
|
|
12
|
+
* rules: { 'atom63/raw-color': ['error', { baseline: baseline['raw-color'] }] }
|
|
13
|
+
*/
|
|
14
|
+
import path from 'node:path'
|
|
15
|
+
import process from 'node:process'
|
|
16
|
+
|
|
17
|
+
let input = ''
|
|
18
|
+
for await (const chunk of process.stdin) input += chunk
|
|
19
|
+
|
|
20
|
+
const baseline = {}
|
|
21
|
+
for (const result of JSON.parse(input)) {
|
|
22
|
+
const file = path.relative(process.cwd(), result.filePath).split(path.sep).join('/')
|
|
23
|
+
for (const message of result.messages) {
|
|
24
|
+
const rule = /^atom63\/(.+)$/.exec(message.ruleId ?? '')?.[1]
|
|
25
|
+
// A file under its baseline reports one "lower the baseline" message; it is not a finding.
|
|
26
|
+
if (!rule || /baseline allows for this rule/.test(message.message)) continue
|
|
27
|
+
baseline[rule] ??= {}
|
|
28
|
+
baseline[rule][file] = (baseline[rule][file] ?? 0) + 1
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const sorted = object =>
|
|
32
|
+
Object.fromEntries(Object.entries(object).sort(([a], [b]) => a.localeCompare(b)))
|
|
33
|
+
for (const rule of Object.keys(baseline)) baseline[rule] = sorted(baseline[rule])
|
|
34
|
+
process.stdout.write(`${JSON.stringify(sorted(baseline), null, 2)}\n`)
|