@activatus/code-standards 3.0.2 → 3.0.5
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 +15 -13
- package/docs/Guides/component-library-workflow.md +16 -16
- package/docs/Guides/migrating.md +18 -16
- package/docs/Guides/setup.md +9 -7
- package/docs/Standards/agent-skills.md +2 -2
- package/docs/Standards/agent-specs.md +3 -3
- package/docs/Standards/documentation.md +7 -7
- package/docs/Standards/eslint.md +321 -155
- package/docs/Standards/human-readable-names.md +15 -3
- package/docs/Standards/lint-errors.md +13 -12
- package/docs/Standards/readable-code.md +82 -43
- package/docs/Standards/stylelint.md +4 -4
- package/docs/Standards/styling.md +8 -8
- package/docs/Standards/tech-stack.md +1 -1
- package/docs/Structure/api-routes.md +3 -3
- package/docs/Structure/component-organization.md +19 -18
- package/docs/Structure/folder-structure.md +131 -12
- package/docs/Structure/naming-conventions.md +10 -8
- package/docs/design-system-components.md +3 -3
- package/docs/intro.md +20 -20
- package/docs/ontology.md +32 -31
- package/docs/templates.mdx +12 -12
- package/docs/version-history.md +77 -42
- package/package.json +19 -4
- package/static/templates/AGENTS.md +6 -5
- package/static/templates/docs/overview/writing-docs.md +1 -1
- package/static/templates/eslint/base/eslint.config.mjs +57 -33
- package/static/templates/eslint/nextjs/eslint.config.mjs +80 -32
- package/static/templates/eslint/react/eslint.config.mjs +76 -33
- package/static/templates/eslint/typescript/eslint.config.mjs +76 -33
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { recommended as eslintCommentsRecommended } from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
2
2
|
import prettier from "eslint-config-prettier";
|
|
3
3
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
4
4
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
@@ -7,7 +7,54 @@ import { flatConfigs as importX } from "eslint-plugin-import-x";
|
|
|
7
7
|
import unicorn from "eslint-plugin-unicorn";
|
|
8
8
|
import globals from "globals";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// Code patterns that are errors in every file.
|
|
11
|
+
const RESTRICTED_SYNTAX = [
|
|
12
|
+
{
|
|
13
|
+
selector: "ClassDeclaration",
|
|
14
|
+
message: "Use functions, not classes.",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
selector: "ClassExpression",
|
|
18
|
+
message: "Use functions, not classes.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
selector: "VariableDeclarator > FunctionExpression",
|
|
22
|
+
message: "Use an arrow function.",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
selector: "VariableDeclaration[kind='let']",
|
|
26
|
+
message:
|
|
27
|
+
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// Functions take one parameter: a single object when they need more than one value.
|
|
32
|
+
// Route handlers are the exception: see below.
|
|
33
|
+
const SINGLE_OBJECT_PARAMETER = [
|
|
34
|
+
{
|
|
35
|
+
selector: "FunctionDeclaration[params.length>1]",
|
|
36
|
+
message:
|
|
37
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
selector:
|
|
41
|
+
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
42
|
+
message:
|
|
43
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
// Deeper than this, return early instead.
|
|
48
|
+
const MAXIMUM_NESTING_DEPTH = 3;
|
|
49
|
+
|
|
50
|
+
// Type a value where it is declared. Story files are the exception: see below.
|
|
51
|
+
const NO_SATISFIES = {
|
|
52
|
+
selector: "TSSatisfiesExpression",
|
|
53
|
+
message:
|
|
54
|
+
"Type a value where it is declared, not with satisfies afterwards.",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const config = [
|
|
11
58
|
{
|
|
12
59
|
ignores: [
|
|
13
60
|
".next/",
|
|
@@ -15,12 +62,14 @@ export default [
|
|
|
15
62
|
"build/",
|
|
16
63
|
"coverage/",
|
|
17
64
|
"next-env.d.ts",
|
|
65
|
+
// The docs viewer is the standard template, with its own packages and build.
|
|
66
|
+
"docsSite/",
|
|
18
67
|
"**/vendor/**",
|
|
19
68
|
],
|
|
20
69
|
},
|
|
21
70
|
...nextVitals,
|
|
22
71
|
...nextTypescript,
|
|
23
|
-
|
|
72
|
+
eslintCommentsRecommended,
|
|
24
73
|
importX.recommended,
|
|
25
74
|
importX.typescript,
|
|
26
75
|
unicorn.configs.recommended,
|
|
@@ -38,7 +87,7 @@ export default [
|
|
|
38
87
|
"@eslint-community/eslint-comments/require-description":
|
|
39
88
|
"error",
|
|
40
89
|
"func-style": ["error", "expression"],
|
|
41
|
-
"max-depth": ["error",
|
|
90
|
+
"max-depth": ["error", MAXIMUM_NESTING_DEPTH],
|
|
42
91
|
"max-lines": [
|
|
43
92
|
"error",
|
|
44
93
|
{ max: 300, skipBlankLines: true, skipComments: true },
|
|
@@ -58,34 +107,9 @@ export default [
|
|
|
58
107
|
],
|
|
59
108
|
"no-restricted-syntax": [
|
|
60
109
|
"error",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
selector: "ClassExpression",
|
|
67
|
-
message: "Use functions, not classes.",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
selector: "VariableDeclarator > FunctionExpression",
|
|
71
|
-
message: "Use an arrow function.",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
selector: "VariableDeclaration[kind='let']",
|
|
75
|
-
message:
|
|
76
|
-
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
selector: "FunctionDeclaration[params.length>1]",
|
|
80
|
-
message:
|
|
81
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
selector:
|
|
85
|
-
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
86
|
-
message:
|
|
87
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
88
|
-
},
|
|
110
|
+
NO_SATISFIES,
|
|
111
|
+
...RESTRICTED_SYNTAX,
|
|
112
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
89
113
|
],
|
|
90
114
|
"import-x/no-cycle": "error",
|
|
91
115
|
"import-x/no-default-export": "error",
|
|
@@ -177,5 +201,29 @@ export default [
|
|
|
177
201
|
files: ["**/*.config.{js,mjs,ts}"],
|
|
178
202
|
rules: { "unicorn/no-top-level-side-effects": "off" },
|
|
179
203
|
},
|
|
204
|
+
{
|
|
205
|
+
// Storybook's own docs type stories with `satisfies Meta<typeof Component>`, so story files may use it.
|
|
206
|
+
files: ["**/*.stories.{ts,tsx}"],
|
|
207
|
+
rules: {
|
|
208
|
+
"no-restricted-syntax": [
|
|
209
|
+
"error",
|
|
210
|
+
...RESTRICTED_SYNTAX,
|
|
211
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
212
|
+
],
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
// Next.js calls a route handler with two values, (request, context), so route.ts files may take two parameters.
|
|
217
|
+
files: ["app/**/route.ts"],
|
|
218
|
+
rules: {
|
|
219
|
+
"no-restricted-syntax": [
|
|
220
|
+
"error",
|
|
221
|
+
NO_SATISFIES,
|
|
222
|
+
...RESTRICTED_SYNTAX,
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
},
|
|
180
226
|
prettier,
|
|
181
227
|
];
|
|
228
|
+
|
|
229
|
+
export default config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import js from "@eslint/js";
|
|
2
|
-
import
|
|
2
|
+
import { recommended as eslintCommentsRecommended } from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
3
3
|
import prettier from "eslint-config-prettier";
|
|
4
4
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
5
5
|
import { flatConfigs as importX } from "eslint-plugin-import-x";
|
|
@@ -9,10 +9,65 @@ import unicorn from "eslint-plugin-unicorn";
|
|
|
9
9
|
import globals from "globals";
|
|
10
10
|
import { configs as typescript } from "typescript-eslint";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Code patterns that are errors in every file.
|
|
13
|
+
const RESTRICTED_SYNTAX = [
|
|
14
|
+
{
|
|
15
|
+
selector: "ClassDeclaration",
|
|
16
|
+
message: "Use functions, not classes.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
selector: "ClassExpression",
|
|
20
|
+
message: "Use functions, not classes.",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
selector: "VariableDeclarator > FunctionExpression",
|
|
24
|
+
message: "Use an arrow function.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
selector: "VariableDeclaration[kind='let']",
|
|
28
|
+
message:
|
|
29
|
+
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
// Functions take one parameter: a single object when they need more than one value.
|
|
34
|
+
const SINGLE_OBJECT_PARAMETER = [
|
|
35
|
+
{
|
|
36
|
+
selector: "FunctionDeclaration[params.length>1]",
|
|
37
|
+
message:
|
|
38
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
selector:
|
|
42
|
+
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
43
|
+
message:
|
|
44
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
// Deeper than this, return early instead.
|
|
49
|
+
const MAXIMUM_NESTING_DEPTH = 3;
|
|
50
|
+
|
|
51
|
+
// Type a value where it is declared. Story files are the exception: see below.
|
|
52
|
+
const NO_SATISFIES = {
|
|
53
|
+
selector: "TSSatisfiesExpression",
|
|
54
|
+
message:
|
|
55
|
+
"Type a value where it is declared, not with satisfies afterwards.",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const config = [
|
|
59
|
+
{
|
|
60
|
+
ignores: [
|
|
61
|
+
"dist/",
|
|
62
|
+
"build/",
|
|
63
|
+
"coverage/",
|
|
64
|
+
// The docs viewer is the standard template, with its own packages and build.
|
|
65
|
+
"docsSite/",
|
|
66
|
+
"**/vendor/**",
|
|
67
|
+
],
|
|
68
|
+
},
|
|
14
69
|
js.configs.recommended,
|
|
15
|
-
|
|
70
|
+
eslintCommentsRecommended,
|
|
16
71
|
importX.recommended,
|
|
17
72
|
importX.typescript,
|
|
18
73
|
unicorn.configs.recommended,
|
|
@@ -34,7 +89,7 @@ export default [
|
|
|
34
89
|
"@eslint-community/eslint-comments/require-description":
|
|
35
90
|
"error",
|
|
36
91
|
"func-style": ["error", "expression"],
|
|
37
|
-
"max-depth": ["error",
|
|
92
|
+
"max-depth": ["error", MAXIMUM_NESTING_DEPTH],
|
|
38
93
|
"max-lines": [
|
|
39
94
|
"error",
|
|
40
95
|
{ max: 300, skipBlankLines: true, skipComments: true },
|
|
@@ -54,34 +109,9 @@ export default [
|
|
|
54
109
|
],
|
|
55
110
|
"no-restricted-syntax": [
|
|
56
111
|
"error",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
selector: "ClassExpression",
|
|
63
|
-
message: "Use functions, not classes.",
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
selector: "VariableDeclarator > FunctionExpression",
|
|
67
|
-
message: "Use an arrow function.",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
selector: "VariableDeclaration[kind='let']",
|
|
71
|
-
message:
|
|
72
|
-
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
selector: "FunctionDeclaration[params.length>1]",
|
|
76
|
-
message:
|
|
77
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
selector:
|
|
81
|
-
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
82
|
-
message:
|
|
83
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
84
|
-
},
|
|
112
|
+
NO_SATISFIES,
|
|
113
|
+
...RESTRICTED_SYNTAX,
|
|
114
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
85
115
|
],
|
|
86
116
|
"import-x/no-cycle": "error",
|
|
87
117
|
"import-x/no-default-export": "error",
|
|
@@ -169,5 +199,18 @@ export default [
|
|
|
169
199
|
files: ["**/*.config.{js,mjs,ts}"],
|
|
170
200
|
rules: { "unicorn/no-top-level-side-effects": "off" },
|
|
171
201
|
},
|
|
202
|
+
{
|
|
203
|
+
// Storybook's own docs type stories with `satisfies Meta<typeof Component>`, so story files may use it.
|
|
204
|
+
files: ["**/*.stories.{ts,tsx}"],
|
|
205
|
+
rules: {
|
|
206
|
+
"no-restricted-syntax": [
|
|
207
|
+
"error",
|
|
208
|
+
...RESTRICTED_SYNTAX,
|
|
209
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
210
|
+
],
|
|
211
|
+
},
|
|
212
|
+
},
|
|
172
213
|
prettier,
|
|
173
214
|
];
|
|
215
|
+
|
|
216
|
+
export default config;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import js from "@eslint/js";
|
|
2
|
-
import
|
|
2
|
+
import { recommended as eslintCommentsRecommended } from "@eslint-community/eslint-plugin-eslint-comments/configs";
|
|
3
3
|
import prettier from "eslint-config-prettier";
|
|
4
4
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
5
5
|
import { flatConfigs as importX } from "eslint-plugin-import-x";
|
|
@@ -7,10 +7,65 @@ import unicorn from "eslint-plugin-unicorn";
|
|
|
7
7
|
import globals from "globals";
|
|
8
8
|
import { configs as typescript } from "typescript-eslint";
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// Code patterns that are errors in every file.
|
|
11
|
+
const RESTRICTED_SYNTAX = [
|
|
12
|
+
{
|
|
13
|
+
selector: "ClassDeclaration",
|
|
14
|
+
message: "Use functions, not classes.",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
selector: "ClassExpression",
|
|
18
|
+
message: "Use functions, not classes.",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
selector: "VariableDeclarator > FunctionExpression",
|
|
22
|
+
message: "Use an arrow function.",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
selector: "VariableDeclaration[kind='let']",
|
|
26
|
+
message:
|
|
27
|
+
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
28
|
+
},
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// Functions take one parameter: a single object when they need more than one value.
|
|
32
|
+
const SINGLE_OBJECT_PARAMETER = [
|
|
33
|
+
{
|
|
34
|
+
selector: "FunctionDeclaration[params.length>1]",
|
|
35
|
+
message:
|
|
36
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
selector:
|
|
40
|
+
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
41
|
+
message:
|
|
42
|
+
"Use a single object parameter when a function needs more than one value.",
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// Deeper than this, return early instead.
|
|
47
|
+
const MAXIMUM_NESTING_DEPTH = 3;
|
|
48
|
+
|
|
49
|
+
// Type a value where it is declared. Story files are the exception: see below.
|
|
50
|
+
const NO_SATISFIES = {
|
|
51
|
+
selector: "TSSatisfiesExpression",
|
|
52
|
+
message:
|
|
53
|
+
"Type a value where it is declared, not with satisfies afterwards.",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const config = [
|
|
57
|
+
{
|
|
58
|
+
ignores: [
|
|
59
|
+
"dist/",
|
|
60
|
+
"build/",
|
|
61
|
+
"coverage/",
|
|
62
|
+
// The docs viewer is the standard template, with its own packages and build.
|
|
63
|
+
"docsSite/",
|
|
64
|
+
"**/vendor/**",
|
|
65
|
+
],
|
|
66
|
+
},
|
|
12
67
|
js.configs.recommended,
|
|
13
|
-
|
|
68
|
+
eslintCommentsRecommended,
|
|
14
69
|
importX.recommended,
|
|
15
70
|
importX.typescript,
|
|
16
71
|
unicorn.configs.recommended,
|
|
@@ -24,7 +79,7 @@ export default [
|
|
|
24
79
|
"@eslint-community/eslint-comments/require-description":
|
|
25
80
|
"error",
|
|
26
81
|
"func-style": ["error", "expression"],
|
|
27
|
-
"max-depth": ["error",
|
|
82
|
+
"max-depth": ["error", MAXIMUM_NESTING_DEPTH],
|
|
28
83
|
"max-lines": [
|
|
29
84
|
"error",
|
|
30
85
|
{ max: 300, skipBlankLines: true, skipComments: true },
|
|
@@ -44,34 +99,9 @@ export default [
|
|
|
44
99
|
],
|
|
45
100
|
"no-restricted-syntax": [
|
|
46
101
|
"error",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
selector: "ClassExpression",
|
|
53
|
-
message: "Use functions, not classes.",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
selector: "VariableDeclarator > FunctionExpression",
|
|
57
|
-
message: "Use an arrow function.",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
selector: "VariableDeclaration[kind='let']",
|
|
61
|
-
message:
|
|
62
|
-
"Use const. If this value really must be reassigned, disable this rule on this line with a comment saying why.",
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
selector: "FunctionDeclaration[params.length>1]",
|
|
66
|
-
message:
|
|
67
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
selector:
|
|
71
|
-
"VariableDeclarator > :matches(ArrowFunctionExpression, FunctionExpression)[params.length>1]",
|
|
72
|
-
message:
|
|
73
|
-
"Use a single object parameter when a function needs more than one value.",
|
|
74
|
-
},
|
|
102
|
+
NO_SATISFIES,
|
|
103
|
+
...RESTRICTED_SYNTAX,
|
|
104
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
75
105
|
],
|
|
76
106
|
"import-x/no-cycle": "error",
|
|
77
107
|
"import-x/no-default-export": "error",
|
|
@@ -150,5 +180,18 @@ export default [
|
|
|
150
180
|
files: ["**/*.config.{js,mjs,ts}"],
|
|
151
181
|
rules: { "unicorn/no-top-level-side-effects": "off" },
|
|
152
182
|
},
|
|
183
|
+
{
|
|
184
|
+
// Storybook's own docs type stories with `satisfies Meta<typeof Component>`, so story files may use it.
|
|
185
|
+
files: ["**/*.stories.{ts,tsx}"],
|
|
186
|
+
rules: {
|
|
187
|
+
"no-restricted-syntax": [
|
|
188
|
+
"error",
|
|
189
|
+
...RESTRICTED_SYNTAX,
|
|
190
|
+
...SINGLE_OBJECT_PARAMETER,
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
153
194
|
prettier,
|
|
154
195
|
];
|
|
196
|
+
|
|
197
|
+
export default config;
|