@devbie/style-guide 1.2.0 → 1.3.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 +50 -22
- package/eslint/base.js +36 -7
- package/eslint/nest.js +29 -0
- package/eslint/next.js +13 -9
- package/package.json +4 -2
- package/eslint/core.js +0 -37
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,15 @@ default, only as a deliberate milestone.
|
|
|
68
87
|
|
|
69
88
|
## Changelog
|
|
70
89
|
|
|
90
|
+
- 1.3.1 — the internal `core` entry is inlined into `base` and removed. Nothing
|
|
91
|
+
imported it directly (`base` was its only consumer), and keeping two files
|
|
92
|
+
for one entry set made the loading order harder to read: `nest` and `next`
|
|
93
|
+
each also end on `prettierConfig`, so there is no shared tail to factor out.
|
|
94
|
+
- 1.3.0 — new `nest` layer backed by `@darraghor/eslint-plugin-nestjs-typed`
|
|
95
|
+
(recommended flat config, four type-aware rules), and `next` reshaped into a
|
|
96
|
+
layer. Consumers now compose `[...base, ...nest]` / `[...base, ...next]`;
|
|
97
|
+
this also lets the newbie monorepo scope the Nest layer to `packages/core`
|
|
98
|
+
via `files` instead of giving a Nest framework standard to its CLIs.
|
|
71
99
|
- 1.2.0 — `backend` renamed to `base` and `frontend` removed. After apits and
|
|
72
100
|
fewbie-cli joined the newbie monorepo (ADR-012/ADR-015), `frontend` had no
|
|
73
101
|
consumer left, and `backend` no longer described its consumers (CLIs, code
|
package/eslint/base.js
CHANGED
|
@@ -1,15 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import tseslint from "typescript-eslint";
|
|
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.
|
|
12
|
+
*
|
|
13
|
+
* Formatting rules (quotes, eol-last, trailing spaces, ...) are deliberately
|
|
14
|
+
* absent: prettier owns formatting. `prettierConfig` is appended last so that
|
|
15
|
+
* composing a layer on top still ends on the formatting-rule shutdown.
|
|
11
16
|
*
|
|
12
17
|
* Repo-specific rules and ignores belong in the consumer's own
|
|
13
18
|
* eslint.config.mjs, spread after this entry.
|
|
14
19
|
*/
|
|
15
|
-
export default [
|
|
20
|
+
export default [
|
|
21
|
+
...tseslint.configs.recommended,
|
|
22
|
+
{
|
|
23
|
+
rules: {
|
|
24
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
25
|
+
"@typescript-eslint/no-unused-vars": [
|
|
26
|
+
"error",
|
|
27
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
|
|
28
|
+
],
|
|
29
|
+
|
|
30
|
+
// Code-quality rules carried over from the legacy gts-derived config.
|
|
31
|
+
"block-scoped-var": "error",
|
|
32
|
+
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
33
|
+
"no-var": "error",
|
|
34
|
+
"prefer-const": "error",
|
|
35
|
+
"prefer-arrow-callback": "error",
|
|
36
|
+
"no-restricted-properties": [
|
|
37
|
+
"error",
|
|
38
|
+
{ object: "describe", property: "only" },
|
|
39
|
+
{ object: "it", property: "only" },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
prettierConfig,
|
|
44
|
+
];
|
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.1",
|
|
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"
|
package/eslint/core.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import tseslint from "typescript-eslint";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Language-level baseline shared by every devbie codebase.
|
|
5
|
-
*
|
|
6
|
-
* Formatting rules (quotes, eol-last, trailing spaces, ...) are deliberately
|
|
7
|
-
* absent: prettier owns formatting. Every public entry appends
|
|
8
|
-
* eslint-config-prettier last so no plugin can re-enable eslint formatting
|
|
9
|
-
* rules afterwards.
|
|
10
|
-
*
|
|
11
|
-
* Internal entry: consumers import `backend`, `frontend` or `next`, never
|
|
12
|
-
* this file.
|
|
13
|
-
*/
|
|
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
|
-
],
|
|
23
|
-
|
|
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
|
-
},
|
|
36
|
-
},
|
|
37
|
-
];
|