@devbie/style-guide 1.2.0 → 1.3.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 +46 -22
- package/eslint/base.js +6 -5
- package/eslint/core.js +2 -2
- package/eslint/nest.js +29 -0
- package/eslint/next.js +13 -9
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,26 +5,44 @@ Single source of truth for code style across the devbie ecosystem
|
|
|
5
5
|
|
|
6
6
|
## Exports
|
|
7
7
|
|
|
8
|
-
| Entry | Contents
|
|
9
|
-
| --------------------------------- |
|
|
10
|
-
| `@devbie/style-guide/prettier` | Canonical prettier config (all repos)
|
|
11
|
-
| `@devbie/style-guide/eslint/base` | eslint flat
|
|
12
|
-
| `@devbie/style-guide/eslint/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
8
|
+
| Entry | Contents |
|
|
9
|
+
| --------------------------------- | ----------------------------------------------- |
|
|
10
|
+
| `@devbie/style-guide/prettier` | Canonical prettier config (all repos) |
|
|
11
|
+
| `@devbie/style-guide/eslint/base` | Baseline eslint flat config for Node TypeScript |
|
|
12
|
+
| `@devbie/style-guide/eslint/nest` | Nest.js layer (Nest-specific rules, type-aware) |
|
|
13
|
+
| `@devbie/style-guide/eslint/next` | Next.js layer (canonical Next.js rules) |
|
|
14
|
+
|
|
15
|
+
`nest` and `next` are **layers, not standalone standards**: every consumer
|
|
16
|
+
composes `[...base, ...nest]` or `[...base, ...next]`. The baseline carries
|
|
17
|
+
the shared language-level rules and prettier; a layer adds only its
|
|
18
|
+
framework's rules. `base` alone covers CLIs, code generators, registries, and
|
|
19
|
+
SDKs.
|
|
20
|
+
|
|
21
|
+
## Coverage: which entry each repo uses
|
|
22
|
+
|
|
23
|
+
| Repo | Composition |
|
|
24
|
+
| ----------------------------------- | ----------------------------------------- |
|
|
25
|
+
| newbie-monorepo root | `base` + `nest` scoped to `packages/core` |
|
|
26
|
+
| newbie-starter, nightwatch-backend | `base` + `nest` |
|
|
27
|
+
| fewbie-starter, nightwatch-frontend | `base` + `next` |
|
|
28
|
+
| newbie-modules | `base` only |
|
|
29
|
+
|
|
30
|
+
Two structural facts drive this table:
|
|
31
|
+
|
|
32
|
+
- `newbie-modules` installs no dependencies at all (modules are copied into a
|
|
33
|
+
consumer, not built in place), so it can only use `base`, which is purely
|
|
34
|
+
syntactic.
|
|
35
|
+
- The newbie monorepo root lints heterogeneous packages in one config: only
|
|
36
|
+
`packages/core` is Nest framework code, while the CLIs, the generator and
|
|
37
|
+
the SDKs are plain Node. ESLint flat config does not read `package.json` and
|
|
38
|
+
nested `eslint.config.mjs` files are not inherited, so per-package
|
|
39
|
+
differentiation must be expressed in the root config with `files` scoping —
|
|
40
|
+
never with per-package config files or `package.json` entry fields.
|
|
41
|
+
|
|
42
|
+
`next` (and `nest`) must be loaded where the framework's packages are
|
|
43
|
+
installed; `eslint-config-next` requires `next` at load time, and the Nest
|
|
44
|
+
layer requires `class-validator` plus a TypeScript project for its four
|
|
45
|
+
type-aware rules.
|
|
28
46
|
|
|
29
47
|
## Usage
|
|
30
48
|
|
|
@@ -48,11 +66,12 @@ not style decisions.
|
|
|
48
66
|
|
|
49
67
|
```js
|
|
50
68
|
import base from "@devbie/style-guide/eslint/base";
|
|
51
|
-
//
|
|
69
|
+
// Nest apps: import nest from "@devbie/style-guide/eslint/nest";
|
|
70
|
+
// Next.js apps: import next from "@devbie/style-guide/eslint/next";
|
|
52
71
|
|
|
53
72
|
export default [
|
|
54
73
|
...base,
|
|
55
|
-
//
|
|
74
|
+
// ...nest or ...next, then repo-specific rules and ignores.
|
|
56
75
|
];
|
|
57
76
|
```
|
|
58
77
|
|
|
@@ -68,6 +87,11 @@ default, only as a deliberate milestone.
|
|
|
68
87
|
|
|
69
88
|
## Changelog
|
|
70
89
|
|
|
90
|
+
- 1.3.0 — new `nest` layer backed by `@darraghor/eslint-plugin-nestjs-typed`
|
|
91
|
+
(recommended flat config, four type-aware rules), and `next` reshaped into a
|
|
92
|
+
layer. Consumers now compose `[...base, ...nest]` / `[...base, ...next]`;
|
|
93
|
+
this also lets the newbie monorepo scope the Nest layer to `packages/core`
|
|
94
|
+
via `files` instead of giving a Nest framework standard to its CLIs.
|
|
71
95
|
- 1.2.0 — `backend` renamed to `base` and `frontend` removed. After apits and
|
|
72
96
|
fewbie-cli joined the newbie monorepo (ADR-012/ADR-015), `frontend` had no
|
|
73
97
|
consumer left, and `backend` no longer described its consumers (CLIs, code
|
package/eslint/base.js
CHANGED
|
@@ -2,12 +2,13 @@ import core from "./core.js";
|
|
|
2
2
|
import prettierConfig from "eslint-config-prettier";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Baseline standard for the devbie ecosystem.
|
|
6
6
|
*
|
|
7
|
-
* Consumers:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Consumers: every repo composes this and optionally adds a framework layer —
|
|
8
|
+
* `[...base, ...nest]` for Nest applications, `[...base, ...next]` for Next.js
|
|
9
|
+
* applications. Repos without a framework (newbie-modules, a dependency-free
|
|
10
|
+
* source registry) use `base` alone: every rule here is syntactic, so it runs
|
|
11
|
+
* without installing module dependencies.
|
|
11
12
|
*
|
|
12
13
|
* Repo-specific rules and ignores belong in the consumer's own
|
|
13
14
|
* eslint.config.mjs, spread after this entry.
|
package/eslint/core.js
CHANGED
|
@@ -8,8 +8,8 @@ import tseslint from "typescript-eslint";
|
|
|
8
8
|
* eslint-config-prettier last so no plugin can re-enable eslint formatting
|
|
9
9
|
* rules afterwards.
|
|
10
10
|
*
|
|
11
|
-
* Internal entry: consumers import `
|
|
12
|
-
* this file.
|
|
11
|
+
* Internal entry: consumers import `base` (or compose a layer such as
|
|
12
|
+
* `nest` / `next` on top of it), never this file.
|
|
13
13
|
*/
|
|
14
14
|
export default [
|
|
15
15
|
...tseslint.configs.recommended,
|
package/eslint/nest.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import nestjsTyped from "@darraghor/eslint-plugin-nestjs-typed";
|
|
2
|
+
import prettierConfig from "eslint-config-prettier";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Nest.js layer for the devbie ecosystem.
|
|
6
|
+
*
|
|
7
|
+
* This is a layer, not a standalone standard: compose it after `base`
|
|
8
|
+
* (`export default [...base, ...nest]`). Keeping it separable lets a
|
|
9
|
+
* monorepo scope the Nest rules to the packages that actually contain Nest
|
|
10
|
+
* code, instead of applying a framework standard to its plain Node packages.
|
|
11
|
+
*
|
|
12
|
+
* The rule set is the plugin's recommended flat config. Four of those rules
|
|
13
|
+
* are type-aware, so every file covered by this layer must belong to a
|
|
14
|
+
* TypeScript project (projectService resolves the nearest tsconfig.json), and
|
|
15
|
+
* the plugin's peers (`class-validator`, `@typescript-eslint/parser`) must be
|
|
16
|
+
* installed by the consumer.
|
|
17
|
+
*
|
|
18
|
+
* `prettierConfig` is repeated here so that composing `[...base, ...nest]`
|
|
19
|
+
* still ends on the formatting-rule shutdown.
|
|
20
|
+
*/
|
|
21
|
+
export default [
|
|
22
|
+
...nestjsTyped.configs.flatRecommended,
|
|
23
|
+
{
|
|
24
|
+
languageOptions: {
|
|
25
|
+
parserOptions: { projectService: true },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
prettierConfig,
|
|
29
|
+
];
|
package/eslint/next.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import core from "./core.js";
|
|
1
|
+
import { globalIgnores } from "eslint/config";
|
|
3
2
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
4
3
|
import nextTs from "eslint-config-next/typescript";
|
|
5
4
|
import prettierConfig from "eslint-config-prettier";
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
* Next.js
|
|
9
|
-
*
|
|
7
|
+
* Next.js layer for the devbie ecosystem.
|
|
8
|
+
*
|
|
9
|
+
* This is a layer, not a standalone standard: compose it after `base`
|
|
10
|
+
* (`export default [...base, ...next]`), so every repo shares the same
|
|
11
|
+
* language-level rules while Next.js applications add only the canonical
|
|
12
|
+
* framework rule set.
|
|
10
13
|
*
|
|
11
|
-
* Extends the shared `core` baseline with the canonical Next rule set.
|
|
12
14
|
* `eslint-config-next` already bundles the React / react-hooks / jsx-a11y
|
|
13
15
|
* layers, so nothing else is layered on top: spreading another React layer
|
|
14
16
|
* would redefine the same plugin and flat config rejects that.
|
|
15
17
|
*
|
|
16
18
|
* This entry can only be loaded where the `next` package is installed; Node
|
|
17
|
-
* repos without a Next runtime
|
|
19
|
+
* repos without a Next runtime compose `base` with `nest` or nothing at all.
|
|
20
|
+
*
|
|
21
|
+
* `prettierConfig` is repeated here so that composing `[...base, ...next]`
|
|
22
|
+
* still ends on the formatting-rule shutdown.
|
|
18
23
|
*/
|
|
19
|
-
export default
|
|
20
|
-
...core,
|
|
24
|
+
export default [
|
|
21
25
|
...nextVitals,
|
|
22
26
|
...nextTs,
|
|
23
27
|
prettierConfig,
|
|
24
28
|
// Framework-generated artifacts; consumers append their own ignores.
|
|
25
29
|
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
|
|
26
|
-
]
|
|
30
|
+
];
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "Single source of truth for devbie ecosystem code style: shared prettier config and composable eslint flat layers (base, nest, next)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "worldzhy",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
"./prettier": "./prettier.js",
|
|
10
10
|
"./eslint/base": "./eslint/base.js",
|
|
11
|
+
"./eslint/nest": "./eslint/nest.js",
|
|
11
12
|
"./eslint/next": "./eslint/next.js",
|
|
12
13
|
"./package.json": "./package.json"
|
|
13
14
|
},
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
23
|
+
"@darraghor/eslint-plugin-nestjs-typed": "^7.5.8",
|
|
22
24
|
"eslint-config-next": "^16.4.2",
|
|
23
25
|
"eslint-config-prettier": "^10.1.8",
|
|
24
26
|
"typescript-eslint": "^8.71.2"
|