@devbie/style-guide 1.0.0 → 1.1.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 +31 -9
- package/eslint/backend.js +15 -0
- package/eslint/{nest.js → core.js} +9 -7
- package/eslint/frontend.js +28 -0
- package/eslint/next.js +6 -3
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
# @devbie/style-guide
|
|
2
2
|
|
|
3
3
|
Single source of truth for code style across the devbie ecosystem
|
|
4
|
-
(newbie / fewbie / nightwatch). See ADR-010 in `worldzhy/newbie`.
|
|
4
|
+
(newbie / fewbie / nightwatch / apits). See ADR-010 in `worldzhy/newbie`.
|
|
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/
|
|
8
|
+
| Entry | Contents |
|
|
9
|
+
| ------------------------------------ | -------------------------------------------------------------- |
|
|
10
|
+
| `@devbie/style-guide/prettier` | Canonical prettier config (all repos) |
|
|
11
|
+
| `@devbie/style-guide/eslint/backend` | eslint flat standard for Nest/Node TypeScript backends |
|
|
12
|
+
| `@devbie/style-guide/eslint/frontend`| eslint flat standard for frontend repos (TS + React + a11y) |
|
|
13
|
+
| `@devbie/style-guide/eslint/next` | Frontend standard + canonical Next.js rules (overlay) |
|
|
14
|
+
|
|
15
|
+
## Which entry each repo uses
|
|
16
|
+
|
|
17
|
+
| Repo | eslint entry |
|
|
18
|
+
| --------------------------------------------------------------------------------- | ------------ |
|
|
19
|
+
| newbie, newbie-starter, nightwatch-backend, newbie-modules, apits | `backend` |
|
|
20
|
+
| fewbie | `frontend` |
|
|
21
|
+
| fewbie-starter, nightwatch-frontend | `next` |
|
|
22
|
+
|
|
23
|
+
`next` is the `frontend` standard plus `eslint-config-next`, so Next.js
|
|
24
|
+
applications and the rest of the frontend group never drift on the shared
|
|
25
|
+
part. `eslint-config-next` requires the `next` package at load time, which is
|
|
26
|
+
why repos without a Next runtime (fewbie) use `frontend` instead.
|
|
13
27
|
|
|
14
28
|
## Usage
|
|
15
29
|
|
|
@@ -32,11 +46,12 @@ not style decisions.
|
|
|
32
46
|
`eslint.config.mjs` in the consumer repo:
|
|
33
47
|
|
|
34
48
|
```js
|
|
35
|
-
import
|
|
36
|
-
//
|
|
49
|
+
import backend from "@devbie/style-guide/eslint/backend";
|
|
50
|
+
// frontend repos: import frontend from "@devbie/style-guide/eslint/frontend";
|
|
51
|
+
// Next.js apps: import next from "@devbie/style-guide/eslint/next";
|
|
37
52
|
|
|
38
53
|
export default [
|
|
39
|
-
...
|
|
54
|
+
...backend,
|
|
40
55
|
// Repo-specific rules and ignores go here.
|
|
41
56
|
];
|
|
42
57
|
```
|
|
@@ -50,3 +65,10 @@ All devbie packages stay on the 1.x line until the ecosystem launches;
|
|
|
50
65
|
breaking style changes bump minor, not major. Dependency major upgrades of
|
|
51
66
|
prettier/eslint follow the ecosystem-wide major-freeze policy: not by
|
|
52
67
|
default, only as a deliberate milestone.
|
|
68
|
+
|
|
69
|
+
## Changelog
|
|
70
|
+
|
|
71
|
+
- 1.1.0 — entries renamed to `backend` / `frontend` and layered: `core` is
|
|
72
|
+
internal, `frontend` is framework-independent (React rules only), `next`
|
|
73
|
+
adds the canonical Next.js rule set. `nest` was replaced by `backend`.
|
|
74
|
+
- 1.0.0 — initial release (`prettier`, `eslint/nest`, `eslint/next`).
|
|
@@ -0,0 +1,15 @@
|
|
|
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];
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import tseslint from "typescript-eslint";
|
|
2
|
-
import prettierConfig from "eslint-config-prettier";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* (nightwatch-backend, newbie-starter, the newbie/fewbie framework repos).
|
|
4
|
+
* Language-level baseline shared by every devbie codebase.
|
|
7
5
|
*
|
|
8
6
|
* Formatting rules (quotes, eol-last, trailing spaces, ...) are deliberately
|
|
9
|
-
* absent: prettier owns formatting
|
|
10
|
-
* eslint
|
|
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.
|
|
11
13
|
*/
|
|
12
|
-
export default
|
|
14
|
+
export default [...tseslint.configs.recommended, {
|
|
13
15
|
rules: {
|
|
14
16
|
"@typescript-eslint/no-explicit-any": "off",
|
|
15
17
|
"@typescript-eslint/no-unused-vars": [
|
|
@@ -25,4 +27,4 @@ export default tseslint.config(...tseslint.configs.recommended, prettierConfig,
|
|
|
25
27
|
"prefer-arrow-callback": "error",
|
|
26
28
|
"no-restricted-properties": ["error", { object: "describe", property: "only" }, { object: "it", property: "only" }],
|
|
27
29
|
},
|
|
28
|
-
}
|
|
30
|
+
}];
|
|
@@ -0,0 +1,28 @@
|
|
|
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 of this
|
|
16
|
+
* standard instead, so every frontend repo shares the same base rules.
|
|
17
|
+
*
|
|
18
|
+
* Repo-specific rules and ignores belong in the consumer's own
|
|
19
|
+
* eslint.config.mjs, spread after this entry.
|
|
20
|
+
*/
|
|
21
|
+
export default [
|
|
22
|
+
...core,
|
|
23
|
+
react.configs.flat.recommended,
|
|
24
|
+
react.configs.flat["jsx-runtime"],
|
|
25
|
+
reactHooks.configs["recommended-latest"],
|
|
26
|
+
jsxA11y.flatConfigs.recommended,
|
|
27
|
+
prettierConfig,
|
|
28
|
+
];
|
package/eslint/next.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import frontend from "./frontend.js";
|
|
2
3
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
3
4
|
import nextTs from "eslint-config-next/typescript";
|
|
4
5
|
import prettierConfig from "eslint-config-prettier";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Next.js overlay for Next.js applications
|
|
8
9
|
* (nightwatch-frontend, fewbie-starter).
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* It extends the shared frontend standard with the canonical Next rule set.
|
|
12
|
+
* This entry can only be loaded where the `next` package is installed, which
|
|
13
|
+
* is why frontend repos without a Next runtime use `frontend` instead.
|
|
12
14
|
*/
|
|
13
15
|
export default defineConfig([
|
|
16
|
+
...frontend,
|
|
14
17
|
...nextVitals,
|
|
15
18
|
...nextTs,
|
|
16
19
|
prettierConfig,
|
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.1.0",
|
|
4
|
+
"description": "Single source of truth for devbie ecosystem code style: shared prettier config and eslint flat standards (backend, frontend, next)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "worldzhy",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
"./prettier": "./prettier.js",
|
|
10
|
-
"./eslint/
|
|
10
|
+
"./eslint/backend": "./eslint/backend.js",
|
|
11
|
+
"./eslint/frontend": "./eslint/frontend.js",
|
|
11
12
|
"./eslint/next": "./eslint/next.js",
|
|
12
13
|
"./package.json": "./package.json"
|
|
13
14
|
},
|
|
@@ -21,6 +22,9 @@
|
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"eslint-config-next": "^16.4.2",
|
|
23
24
|
"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",
|
|
24
28
|
"typescript-eslint": "^8.71.2"
|
|
25
29
|
},
|
|
26
30
|
"peerDependencies": {
|