@devbie/style-guide 0.0.0-stage → 1.0.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 +51 -2
- package/eslint/nest.js +28 -0
- package/eslint/next.js +19 -0
- package/package.json +29 -4
- package/prettier.js +29 -0
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
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`.
|
|
5
|
+
|
|
6
|
+
## Exports
|
|
7
|
+
|
|
8
|
+
| Entry | Contents |
|
|
9
|
+
| --------------------------------- | ----------------------------------------------------- |
|
|
10
|
+
| `@devbie/style-guide/prettier` | Canonical prettier config |
|
|
11
|
+
| `@devbie/style-guide/eslint/nest` | eslint flat config for Nest/Node TypeScript codebases |
|
|
12
|
+
| `@devbie/style-guide/eslint/next` | eslint flat config for Next.js codebases |
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
### prettier
|
|
17
|
+
|
|
18
|
+
Delete any local `.prettierrc` and reference the shared config in
|
|
19
|
+
`package.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"prettier": "@devbie/style-guide/prettier"
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`.prettierignore` stays repo-local: it lists repo-specific build artifacts,
|
|
28
|
+
not style decisions.
|
|
29
|
+
|
|
30
|
+
### eslint (flat config)
|
|
31
|
+
|
|
32
|
+
`eslint.config.mjs` in the consumer repo:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import nest from "@devbie/style-guide/eslint/nest";
|
|
36
|
+
// or: import next from "@devbie/style-guide/eslint/next";
|
|
37
|
+
|
|
38
|
+
export default [
|
|
39
|
+
...next,
|
|
40
|
+
// Repo-specific rules and ignores go here.
|
|
41
|
+
];
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Consumers need `eslint` (^9 or ^10), `prettier` (^3.9.9) and `typescript`
|
|
45
|
+
installed as their own dev dependencies (declared as peers of this package).
|
|
46
|
+
|
|
47
|
+
## Version policy
|
|
48
|
+
|
|
49
|
+
All devbie packages stay on the 1.x line until the ecosystem launches;
|
|
50
|
+
breaking style changes bump minor, not major. Dependency major upgrades of
|
|
51
|
+
prettier/eslint follow the ecosystem-wide major-freeze policy: not by
|
|
52
|
+
default, only as a deliberate milestone.
|
package/eslint/nest.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import tseslint from "typescript-eslint";
|
|
2
|
+
import prettierConfig from "eslint-config-prettier";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared eslint flat config for Nest/Node TypeScript codebases
|
|
6
|
+
* (nightwatch-backend, newbie-starter, the newbie/fewbie framework repos).
|
|
7
|
+
*
|
|
8
|
+
* Formatting rules (quotes, eol-last, trailing spaces, ...) are deliberately
|
|
9
|
+
* absent: prettier owns formatting, and eslint-config-prettier disables the
|
|
10
|
+
* eslint side. Prettier violations are enforced by `npm run format:check`.
|
|
11
|
+
*/
|
|
12
|
+
export default tseslint.config(...tseslint.configs.recommended, prettierConfig, {
|
|
13
|
+
rules: {
|
|
14
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
15
|
+
"@typescript-eslint/no-unused-vars": [
|
|
16
|
+
"error",
|
|
17
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_" },
|
|
18
|
+
],
|
|
19
|
+
|
|
20
|
+
// Code-quality rules carried over from the legacy gts-derived config.
|
|
21
|
+
"block-scoped-var": "error",
|
|
22
|
+
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
23
|
+
"no-var": "error",
|
|
24
|
+
"prefer-const": "error",
|
|
25
|
+
"prefer-arrow-callback": "error",
|
|
26
|
+
"no-restricted-properties": ["error", { object: "describe", property: "only" }, { object: "it", property: "only" }],
|
|
27
|
+
},
|
|
28
|
+
});
|
package/eslint/next.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
3
|
+
import nextTs from "eslint-config-next/typescript";
|
|
4
|
+
import prettierConfig from "eslint-config-prettier";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Shared eslint flat config for Next.js codebases
|
|
8
|
+
* (nightwatch-frontend, fewbie-starter).
|
|
9
|
+
*
|
|
10
|
+
* Repo-specific rules and ignores belong in the consumer's own
|
|
11
|
+
* eslint.config.mjs, spread after this entry.
|
|
12
|
+
*/
|
|
13
|
+
export default defineConfig([
|
|
14
|
+
...nextVitals,
|
|
15
|
+
...nextTs,
|
|
16
|
+
prettierConfig,
|
|
17
|
+
// Framework-generated artifacts; consumers append their own ignores.
|
|
18
|
+
globalIgnores([".next/**", "out/**", "build/**", "next-env.d.ts"]),
|
|
19
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devbie/style-guide",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Single source of truth for devbie ecosystem code style: shared prettier config and eslint flat configs (Nest and Next entries)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "worldzhy",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./prettier": "./prettier.js",
|
|
10
|
+
"./eslint/nest": "./eslint/nest.js",
|
|
11
|
+
"./eslint/next": "./eslint/next.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"prettier.js",
|
|
16
|
+
"eslint"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"eslint-config-next": "^16.4.2",
|
|
23
|
+
"eslint-config-prettier": "^10.1.8",
|
|
24
|
+
"typescript-eslint": "^8.71.2"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"eslint": "^9.0.0 || ^10.0.0",
|
|
28
|
+
"prettier": "^3.9.9",
|
|
29
|
+
"typescript": ">=5.0.0"
|
|
30
|
+
}
|
|
31
|
+
}
|
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
|
+
};
|