@devbie/style-guide 1.1.2 → 1.2.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/README.md +32 -23
- package/eslint/base.js +15 -0
- package/eslint/core.js +22 -15
- package/eslint/next.js +3 -3
- package/package.json +3 -7
- package/eslint/backend.js +0 -15
- package/eslint/frontend.js +0 -31
package/README.md
CHANGED
|
@@ -5,27 +5,26 @@ Single source of truth for code style across the devbie ecosystem
|
|
|
5
5
|
|
|
6
6
|
## Exports
|
|
7
7
|
|
|
8
|
-
| Entry
|
|
9
|
-
|
|
|
10
|
-
| `@devbie/style-guide/prettier`
|
|
11
|
-
| `@devbie/style-guide/eslint/
|
|
12
|
-
| `@devbie/style-guide/eslint/
|
|
13
|
-
| `@devbie/style-guide/eslint/next` | Frontend standard + canonical Next.js rules (overlay) |
|
|
8
|
+
| Entry | Contents |
|
|
9
|
+
| --------------------------------- | --------------------------------------------------- |
|
|
10
|
+
| `@devbie/style-guide/prettier` | Canonical prettier config (all repos) |
|
|
11
|
+
| `@devbie/style-guide/eslint/base` | eslint flat standard for Node TypeScript repos |
|
|
12
|
+
| `@devbie/style-guide/eslint/next` | `base` + canonical Next.js rules (for Next.js apps) |
|
|
14
13
|
|
|
15
14
|
## Which entry each repo uses
|
|
16
15
|
|
|
17
|
-
| Repo
|
|
18
|
-
|
|
|
19
|
-
| newbie, newbie-starter, nightwatch-backend, newbie-modules
|
|
20
|
-
| fewbie
|
|
21
|
-
| fewbie-starter, nightwatch-frontend | `next` |
|
|
16
|
+
| Repo | eslint entry |
|
|
17
|
+
| ---------------------------------------------------------- | ------------ |
|
|
18
|
+
| newbie, newbie-starter, nightwatch-backend, newbie-modules | `base` |
|
|
19
|
+
| fewbie-starter, nightwatch-frontend | `next` |
|
|
22
20
|
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
`base` is the shared default: language-level rules plus prettier, with no
|
|
22
|
+
framework content — it serves Nest services, CLIs, code generators, and
|
|
23
|
+
source registries alike. `next` is `base`'s baseline plus `eslint-config-next`
|
|
24
|
+
(which already bundles the React / react-hooks / jsx-a11y layers), so every
|
|
25
|
+
repo shares the same language-level rules while Next.js applications add only
|
|
26
|
+
the canonical framework layer. `eslint-config-next` requires the `next`
|
|
27
|
+
package at load time, which is why Node repos cannot use `next`.
|
|
29
28
|
|
|
30
29
|
## Usage
|
|
31
30
|
|
|
@@ -48,12 +47,11 @@ not style decisions.
|
|
|
48
47
|
`eslint.config.mjs` in the consumer repo:
|
|
49
48
|
|
|
50
49
|
```js
|
|
51
|
-
import
|
|
52
|
-
//
|
|
53
|
-
// Next.js apps: import next from "@devbie/style-guide/eslint/next";
|
|
50
|
+
import base from "@devbie/style-guide/eslint/base";
|
|
51
|
+
// Next.js apps: import next from "@devbie/style-guide/eslint/next";
|
|
54
52
|
|
|
55
53
|
export default [
|
|
56
|
-
...
|
|
54
|
+
...base,
|
|
57
55
|
// Repo-specific rules and ignores go here.
|
|
58
56
|
];
|
|
59
57
|
```
|
|
@@ -70,11 +68,22 @@ default, only as a deliberate milestone.
|
|
|
70
68
|
|
|
71
69
|
## Changelog
|
|
72
70
|
|
|
71
|
+
- 1.2.0 — `backend` renamed to `base` and `frontend` removed. After apits and
|
|
72
|
+
fewbie-cli joined the newbie monorepo (ADR-012/ADR-015), `frontend` had no
|
|
73
|
+
consumer left, and `backend` no longer described its consumers (CLIs, code
|
|
74
|
+
generators, registries — none of them backends). The pair is now named for
|
|
75
|
+
what it is: `base` (the default) and `next` (the Next.js specialization).
|
|
76
|
+
The react/react-hooks/jsx-a11y plugin dependencies are dropped; `next`
|
|
77
|
+
gets those layers from `eslint-config-next`.
|
|
78
|
+
- 1.1.3 — `frontend` pins the React version for rule evaluation (19.0) instead
|
|
79
|
+
of detecting it: fewbie lints React template sources without a `react`
|
|
80
|
+
package installed, where detection only emits a warning.
|
|
73
81
|
- 1.1.2 — fix: `next` extends `core` plus the canonical Next rule set
|
|
74
82
|
(`eslint-config-next` already bundles React/react-hooks/jsx-a11y, so
|
|
75
83
|
spreading `frontend` on top redefined `jsx-a11y` and flat config rejected
|
|
76
|
-
it). The `frontend` React layer is now scoped to JSX/TSX files, so
|
|
77
|
-
|
|
84
|
+
it). The `frontend` React layer is now scoped to JSX/TSX files, so Node code
|
|
85
|
+
in frontend repos is not evaluated against React rules while React template
|
|
86
|
+
sources are.
|
|
78
87
|
- 1.1.1 — fix: `frontend` uses the flat variant of eslint-plugin-react-hooks
|
|
79
88
|
(`configs.flat["recommended-latest"]`); 1.1.0 shipped the legacy shape and
|
|
80
89
|
failed to load under flat config.
|
package/eslint/base.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import core from "./core.js";
|
|
2
|
+
import prettierConfig from "eslint-config-prettier";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base standard for the devbie ecosystem.
|
|
6
|
+
*
|
|
7
|
+
* Consumers: newbie (monorepo), newbie-starter, nightwatch-backend,
|
|
8
|
+
* newbie-modules, apits, fewbie-cli (inside newbie). All of them are Node.js
|
|
9
|
+
* TypeScript codebases — no browser DOM framework. The language-level rules
|
|
10
|
+
* live in `core` so base and next standards never drift on the shared part.
|
|
11
|
+
*
|
|
12
|
+
* Repo-specific rules and ignores belong in the consumer's own
|
|
13
|
+
* eslint.config.mjs, spread after this entry.
|
|
14
|
+
*/
|
|
15
|
+
export default [...core, prettierConfig];
|
package/eslint/core.js
CHANGED
|
@@ -11,20 +11,27 @@ import tseslint from "typescript-eslint";
|
|
|
11
11
|
* Internal entry: consumers import `backend`, `frontend` or `next`, never
|
|
12
12
|
* this file.
|
|
13
13
|
*/
|
|
14
|
-
export default [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
export default [
|
|
15
|
+
...tseslint.configs.recommended,
|
|
16
|
+
{
|
|
17
|
+
rules: {
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-unused-vars": [
|
|
20
|
+
"error",
|
|
21
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
|
|
22
|
+
],
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
// Code-quality rules carried over from the legacy gts-derived config.
|
|
25
|
+
"block-scoped-var": "error",
|
|
26
|
+
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
27
|
+
"no-var": "error",
|
|
28
|
+
"prefer-const": "error",
|
|
29
|
+
"prefer-arrow-callback": "error",
|
|
30
|
+
"no-restricted-properties": [
|
|
31
|
+
"error",
|
|
32
|
+
{ object: "describe", property: "only" },
|
|
33
|
+
{ object: "it", property: "only" },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
29
36
|
},
|
|
30
|
-
|
|
37
|
+
];
|
package/eslint/next.js
CHANGED
|
@@ -10,11 +10,11 @@ import prettierConfig from "eslint-config-prettier";
|
|
|
10
10
|
*
|
|
11
11
|
* Extends the shared `core` baseline with the canonical Next rule set.
|
|
12
12
|
* `eslint-config-next` already bundles the React / react-hooks / jsx-a11y
|
|
13
|
-
* layers, so
|
|
13
|
+
* layers, so nothing else is layered on top: spreading another React layer
|
|
14
14
|
* would redefine the same plugin and flat config rejects that.
|
|
15
15
|
*
|
|
16
|
-
* This entry can only be loaded where the `next` package is installed
|
|
17
|
-
*
|
|
16
|
+
* This entry can only be loaded where the `next` package is installed; Node
|
|
17
|
+
* repos without a Next runtime use the `base` entry instead.
|
|
18
18
|
*/
|
|
19
19
|
export default defineConfig([
|
|
20
20
|
...core,
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devbie/style-guide",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Single source of truth for devbie ecosystem code style: shared prettier config and eslint flat standards (
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Single source of truth for devbie ecosystem code style: shared prettier config and eslint flat standards (base, next)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "worldzhy",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
"./prettier": "./prettier.js",
|
|
10
|
-
"./eslint/
|
|
11
|
-
"./eslint/frontend": "./eslint/frontend.js",
|
|
10
|
+
"./eslint/base": "./eslint/base.js",
|
|
12
11
|
"./eslint/next": "./eslint/next.js",
|
|
13
12
|
"./package.json": "./package.json"
|
|
14
13
|
},
|
|
@@ -22,9 +21,6 @@
|
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"eslint-config-next": "^16.4.2",
|
|
24
23
|
"eslint-config-prettier": "^10.1.8",
|
|
25
|
-
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
26
|
-
"eslint-plugin-react": "^7.37.0",
|
|
27
|
-
"eslint-plugin-react-hooks": "^7.1.0",
|
|
28
24
|
"typescript-eslint": "^8.71.2"
|
|
29
25
|
},
|
|
30
26
|
"peerDependencies": {
|
package/eslint/backend.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import core from "./core.js";
|
|
2
|
-
import prettierConfig from "eslint-config-prettier";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Backend standard for the devbie ecosystem.
|
|
6
|
-
*
|
|
7
|
-
* Consumers: newbie, newbie-starter, nightwatch-backend, newbie-modules,
|
|
8
|
-
* apits. All of them are Nest/Node TypeScript codebases; the language-level
|
|
9
|
-
* rules live in `core` so the backend and frontend standards never drift on
|
|
10
|
-
* the shared part.
|
|
11
|
-
*
|
|
12
|
-
* Repo-specific rules and ignores belong in the consumer's own
|
|
13
|
-
* eslint.config.mjs, spread after this entry.
|
|
14
|
-
*/
|
|
15
|
-
export default [...core, prettierConfig];
|
package/eslint/frontend.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import core from "./core.js";
|
|
2
|
-
import prettierConfig from "eslint-config-prettier";
|
|
3
|
-
import react from "eslint-plugin-react";
|
|
4
|
-
import reactHooks from "eslint-plugin-react-hooks";
|
|
5
|
-
import jsxA11y from "eslint-plugin-jsx-a11y";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Frontend standard for the devbie ecosystem.
|
|
9
|
-
*
|
|
10
|
-
* Consumers: fewbie, fewbie-starter, nightwatch-frontend.
|
|
11
|
-
*
|
|
12
|
-
* Deliberately independent of `eslint-config-next`: that package requires the
|
|
13
|
-
* `next` package to be installed (its parser is `next/dist/compiled/babel
|
|
14
|
-
* /eslint-parser`), while fewbie ships a Node CLI and has no Next runtime.
|
|
15
|
-
* Next.js applications layer `@devbie/style-guide/eslint/next` on top instead.
|
|
16
|
-
*
|
|
17
|
-
* The JSX/React layer is scoped to JSX/TSX files: repositories in the
|
|
18
|
-
* frontend group that carry no React code (fewbie-cli) receive the same
|
|
19
|
-
* standard without evaluating React rules at all.
|
|
20
|
-
*/
|
|
21
|
-
const jsxFiles = ["**/*.jsx", "**/*.tsx"];
|
|
22
|
-
const jsxOnly = (config) => ({ ...config, files: jsxFiles });
|
|
23
|
-
|
|
24
|
-
export default [
|
|
25
|
-
...core,
|
|
26
|
-
jsxOnly(react.configs.flat.recommended),
|
|
27
|
-
jsxOnly(react.configs.flat["jsx-runtime"]),
|
|
28
|
-
jsxOnly(reactHooks.configs.flat["recommended-latest"]),
|
|
29
|
-
jsxOnly(jsxA11y.flatConfigs.recommended),
|
|
30
|
-
prettierConfig,
|
|
31
|
-
];
|