@devbie/style-guide 0.0.0-stage → 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 CHANGED
@@ -1,3 +1,74 @@
1
- # Temporary Holding Version
1
+ # @devbie/style-guide
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Single source of truth for code style across the devbie ecosystem
4
+ (newbie / fewbie / nightwatch / apits). See ADR-010 in `worldzhy/newbie`.
5
+
6
+ ## Exports
7
+
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.
27
+
28
+ ## Usage
29
+
30
+ ### prettier
31
+
32
+ Delete any local `.prettierrc` and reference the shared config in
33
+ `package.json`:
34
+
35
+ ```json
36
+ {
37
+ "prettier": "@devbie/style-guide/prettier"
38
+ }
39
+ ```
40
+
41
+ `.prettierignore` stays repo-local: it lists repo-specific build artifacts,
42
+ not style decisions.
43
+
44
+ ### eslint (flat config)
45
+
46
+ `eslint.config.mjs` in the consumer repo:
47
+
48
+ ```js
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";
52
+
53
+ export default [
54
+ ...backend,
55
+ // Repo-specific rules and ignores go here.
56
+ ];
57
+ ```
58
+
59
+ Consumers need `eslint` (^9 or ^10), `prettier` (^3.9.9) and `typescript`
60
+ installed as their own dev dependencies (declared as peers of this package).
61
+
62
+ ## Version policy
63
+
64
+ All devbie packages stay on the 1.x line until the ecosystem launches;
65
+ breaking style changes bump minor, not major. Dependency major upgrades of
66
+ prettier/eslint follow the ecosystem-wide major-freeze policy: not by
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];
package/eslint/core.js ADDED
@@ -0,0 +1,30 @@
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 [...tseslint.configs.recommended, {
15
+ rules: {
16
+ "@typescript-eslint/no-explicit-any": "off",
17
+ "@typescript-eslint/no-unused-vars": [
18
+ "error",
19
+ { argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
20
+ ],
21
+
22
+ // Code-quality rules carried over from the legacy gts-derived config.
23
+ "block-scoped-var": "error",
24
+ eqeqeq: ["error", "always", { null: "ignore" }],
25
+ "no-var": "error",
26
+ "prefer-const": "error",
27
+ "prefer-arrow-callback": "error",
28
+ "no-restricted-properties": ["error", { object: "describe", property: "only" }, { object: "it", property: "only" }],
29
+ },
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 ADDED
@@ -0,0 +1,22 @@
1
+ import { defineConfig, globalIgnores } from "eslint/config";
2
+ import frontend from "./frontend.js";
3
+ import nextVitals from "eslint-config-next/core-web-vitals";
4
+ import nextTs from "eslint-config-next/typescript";
5
+ import prettierConfig from "eslint-config-prettier";
6
+
7
+ /**
8
+ * Next.js overlay for Next.js applications
9
+ * (nightwatch-frontend, fewbie-starter).
10
+ *
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.
14
+ */
15
+ export default defineConfig([
16
+ ...frontend,
17
+ ...nextVitals,
18
+ ...nextTs,
19
+ prettierConfig,
20
+ // Framework-generated artifacts; consumers append their own ignores.
21
+ globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
22
+ ]);
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@devbie/style-guide",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
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
+ "license": "MIT",
6
+ "author": "worldzhy",
7
+ "type": "module",
8
+ "exports": {
9
+ "./prettier": "./prettier.js",
10
+ "./eslint/backend": "./eslint/backend.js",
11
+ "./eslint/frontend": "./eslint/frontend.js",
12
+ "./eslint/next": "./eslint/next.js",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "prettier.js",
17
+ "eslint"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "eslint-config-next": "^16.4.2",
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",
28
+ "typescript-eslint": "^8.71.2"
29
+ },
30
+ "peerDependencies": {
31
+ "eslint": "^9.0.0 || ^10.0.0",
32
+ "prettier": "^3.9.9",
33
+ "typescript": ">=5.0.0"
34
+ }
35
+ }
package/prettier.js ADDED
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Canonical prettier config for the devbie ecosystem.
3
+ * Consumers reference it via `"prettier": "@devbie/style-guide/prettier"`
4
+ * in their package.json instead of keeping a local .prettierrc copy.
5
+ *
6
+ * @type {import("prettier").Config}
7
+ */
8
+ export default {
9
+ printWidth: 120,
10
+ tabWidth: 2,
11
+ useTabs: false,
12
+ semi: true,
13
+ singleQuote: false,
14
+ jsxSingleQuote: false,
15
+ quoteProps: "as-needed",
16
+ trailingComma: "all",
17
+ bracketSpacing: true,
18
+ bracketSameLine: false,
19
+ arrowParens: "always",
20
+ singleAttributePerLine: false,
21
+ objectWrap: "preserve",
22
+ htmlWhitespaceSensitivity: "css",
23
+ embeddedLanguageFormatting: "auto",
24
+ endOfLine: "lf",
25
+ proseWrap: "preserve",
26
+ insertPragma: false,
27
+ requirePragma: false,
28
+ experimentalTernaries: false,
29
+ };