@zgeoff/oxlint-config 0.2.1 → 0.2.3
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 +7 -11
- package/function-verb.js +13 -0
- package/no-comment-rule-override.js +74 -0
- package/oxlintrc.json +22 -0
- package/package.json +2 -1
- package/plugin.js +2 -0
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ restriction-rule cherry-picks, comment-style enforcement via `@stylistic`, and a
|
|
|
5
5
|
(`zgeoff/*` rules) banning shapes no native oxlint rule can express — top-level arrows, nested
|
|
6
6
|
function declarations, bare named exports, destructured and inline-typed parameters, ternary and
|
|
7
7
|
await arguments, awaits hidden inside a control-flow condition or a `&&`/`||`/`??` chain, every
|
|
8
|
-
JSDoc block,
|
|
9
|
-
function-naming taxonomy from the shared agent guidelines,
|
|
10
|
-
test file beside the module it tests, and
|
|
11
|
-
module boundary the repo declares.
|
|
8
|
+
JSDoc block, any run of more than three line comments, and a repo config that loosens either comment
|
|
9
|
+
rule. `zgeoff/function-verb` enforces the function-naming taxonomy from the shared agent guidelines,
|
|
10
|
+
`zgeoff/test-beside-module` keeps each test file beside the module it tests, and
|
|
11
|
+
`zgeoff/import-zones` fails an import that crosses a module boundary the repo declares.
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
@@ -65,13 +65,9 @@ comments longer than `max` (default 3); tool directives (`oxlint-`, `eslint-`, `
|
|
|
65
65
|
count nor join the prose around them. Neither rule fixes: a deleted comment is a decision, not a
|
|
66
66
|
whitespace change.
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"zgeoff/max-consecutive-line-comments": ["error", { "max": 3 }],
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
```
|
|
68
|
+
Every repo runs both rules as this config ships them. `zgeoff/no-comment-rule-override` reports a
|
|
69
|
+
repo-root `.oxlintrc*.json` that sets either rule, once per lint run, so a repo cannot turn them off
|
|
70
|
+
or loosen `max`.
|
|
75
71
|
|
|
76
72
|
## `zgeoff/test-beside-module`
|
|
77
73
|
|
package/function-verb.js
CHANGED
|
@@ -25,6 +25,7 @@ const taxonomyVerbs = [
|
|
|
25
25
|
'format',
|
|
26
26
|
'render',
|
|
27
27
|
'normalize',
|
|
28
|
+
'sanitize',
|
|
28
29
|
'resolve',
|
|
29
30
|
'expand',
|
|
30
31
|
'compress',
|
|
@@ -33,18 +34,28 @@ const taxonomyVerbs = [
|
|
|
33
34
|
'transform',
|
|
34
35
|
'apply',
|
|
35
36
|
'create',
|
|
37
|
+
'mint',
|
|
38
|
+
'open',
|
|
39
|
+
'dispose',
|
|
36
40
|
'claim',
|
|
41
|
+
'release',
|
|
42
|
+
'revoke',
|
|
37
43
|
'read',
|
|
38
44
|
'load',
|
|
39
45
|
'write',
|
|
40
46
|
'remove',
|
|
41
47
|
'update',
|
|
48
|
+
'refresh',
|
|
42
49
|
'upsert',
|
|
43
50
|
'set',
|
|
44
51
|
'toggle',
|
|
45
52
|
'reset',
|
|
53
|
+
'restore',
|
|
46
54
|
'print',
|
|
55
|
+
'record',
|
|
47
56
|
'run',
|
|
57
|
+
'spawn',
|
|
58
|
+
'schedule',
|
|
48
59
|
'check',
|
|
49
60
|
'try',
|
|
50
61
|
'register',
|
|
@@ -60,6 +71,8 @@ const taxonomyVerbs = [
|
|
|
60
71
|
'teardown',
|
|
61
72
|
'start',
|
|
62
73
|
'stop',
|
|
74
|
+
'restart',
|
|
75
|
+
'advance',
|
|
63
76
|
'drain',
|
|
64
77
|
'with',
|
|
65
78
|
'make',
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import findRepoRoot from './find-repo-root.js';
|
|
4
|
+
|
|
5
|
+
// every repo runs the comment rules exactly as this config ships them
|
|
6
|
+
const lockedRules = ['zgeoff/no-jsdoc', 'zgeoff/max-consecutive-line-comments'];
|
|
7
|
+
|
|
8
|
+
const configPattern = /^\.oxlintrc(?:\.[\w-]+)?\.jsonc?$/u;
|
|
9
|
+
|
|
10
|
+
// a rule key, as opposed to the same text inside a comment or a string value
|
|
11
|
+
const keyPatterns = lockedRules.map((rule) => ({
|
|
12
|
+
rule,
|
|
13
|
+
pattern: new RegExp(`"${rule}"\\s*:`, 'u'),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
// the one file per repo that carries the report, so a repo with an override
|
|
17
|
+
// sees it once per run rather than on every file, and an editor's language
|
|
18
|
+
// server keeps it on that file across edits
|
|
19
|
+
const anchorFiles = new Map();
|
|
20
|
+
|
|
21
|
+
function buildCommentFreeText(text) {
|
|
22
|
+
return text.replaceAll(
|
|
23
|
+
/(?<string>"(?:\\.|[^"\\])*")|\/\/[^\n]*|\/\*[\s\S]*?\*\//gu,
|
|
24
|
+
(...match) => match.at(-1).string ?? '',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function loadOverrides(root) {
|
|
29
|
+
const configs = readdirSync(root).filter((name) => configPattern.test(name));
|
|
30
|
+
|
|
31
|
+
return configs.flatMap((name) => {
|
|
32
|
+
const text = buildCommentFreeText(readFileSync(join(root, name), 'utf8'));
|
|
33
|
+
|
|
34
|
+
return keyPatterns
|
|
35
|
+
.filter((entry) => entry.pattern.test(text))
|
|
36
|
+
.map((entry) => ({ config: name, rule: entry.rule }));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const noCommentRuleOverride = {
|
|
41
|
+
meta: {
|
|
42
|
+
type: 'problem',
|
|
43
|
+
messages: {
|
|
44
|
+
override:
|
|
45
|
+
'{{config}} sets {{rule}}. Delete the setting: every repo runs the comment rules as @zgeoff/oxlint-config ships them.',
|
|
46
|
+
},
|
|
47
|
+
schema: [],
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
const root = findRepoRoot(context.filename);
|
|
51
|
+
|
|
52
|
+
if (root === null) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!anchorFiles.has(root)) {
|
|
57
|
+
anchorFiles.set(root, context.filename);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (anchorFiles.get(root) !== context.filename) {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
Program(node) {
|
|
66
|
+
for (const override of loadOverrides(root)) {
|
|
67
|
+
context.report({ node, messageId: 'override', data: override });
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default noCommentRuleOverride;
|
package/oxlintrc.json
CHANGED
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"zgeoff/no-await-in-logical": "error",
|
|
28
28
|
"zgeoff/no-jsdoc": "error",
|
|
29
29
|
"zgeoff/max-consecutive-line-comments": ["error", { "max": 3 }],
|
|
30
|
+
"zgeoff/no-comment-rule-override": "error",
|
|
30
31
|
"zgeoff/function-verb": "error",
|
|
31
32
|
"zgeoff/test-beside-module": "error",
|
|
32
33
|
|
|
@@ -122,6 +123,27 @@
|
|
|
122
123
|
// this config targets node/bun tooling — node builtins are the platform
|
|
123
124
|
"import/no-nodejs-modules": "off",
|
|
124
125
|
|
|
126
|
+
// a file past 500 non-blank lines holds more than one concept, and a fifth
|
|
127
|
+
// parameter wants an options object
|
|
128
|
+
"max-lines": ["error", { "max": 500, "skipBlankLines": true }],
|
|
129
|
+
"max-params": ["error", { "max": 4 }],
|
|
130
|
+
|
|
131
|
+
// counts that fire on code already in its clearest form
|
|
132
|
+
"max-statements": "off",
|
|
133
|
+
"max-lines-per-function": "off",
|
|
134
|
+
"import/max-dependencies": "off",
|
|
135
|
+
|
|
136
|
+
// the fix reads worse than the code: tsc checks assignment before use, a
|
|
137
|
+
// guard `continue` is an early return, awaits in a loop keep order, and
|
|
138
|
+
// an event or timer needs a bare `new Promise`
|
|
139
|
+
"init-declarations": "off",
|
|
140
|
+
"no-continue": "off",
|
|
141
|
+
"no-await-in-loop": "off",
|
|
142
|
+
"promise/avoid-new": "off",
|
|
143
|
+
|
|
144
|
+
// a library or platform handle has no readonly form
|
|
145
|
+
"typescript/prefer-readonly-parameter-types": "off",
|
|
146
|
+
|
|
125
147
|
// preload-style modules (matcher registration, type augmentation) are
|
|
126
148
|
// side-effect imports by design
|
|
127
149
|
"import/no-unassigned-import": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgeoff/oxlint-config",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Shareable oxlint config: strict categories, house-style rules, and a custom JS plugin",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"function-verb.js",
|
|
15
15
|
"max-consecutive-line-comments.js",
|
|
16
16
|
"no-jsdoc.js",
|
|
17
|
+
"no-comment-rule-override.js",
|
|
17
18
|
"test-beside-module.js",
|
|
18
19
|
"import-zones.js",
|
|
19
20
|
"import-zones-schema.js",
|
package/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import functionVerb from './function-verb.js';
|
|
2
2
|
import importZones from './import-zones.js';
|
|
3
3
|
import maxConsecutiveLineComments from './max-consecutive-line-comments.js';
|
|
4
|
+
import noCommentRuleOverride from './no-comment-rule-override.js';
|
|
4
5
|
import noJSDoc from './no-jsdoc.js';
|
|
5
6
|
import testBesideModule from './test-beside-module.js';
|
|
6
7
|
|
|
@@ -96,6 +97,7 @@ const plugin = {
|
|
|
96
97
|
),
|
|
97
98
|
'no-jsdoc': noJSDoc,
|
|
98
99
|
'max-consecutive-line-comments': maxConsecutiveLineComments,
|
|
100
|
+
'no-comment-rule-override': noCommentRuleOverride,
|
|
99
101
|
'function-verb': functionVerb,
|
|
100
102
|
'test-beside-module': testBesideModule,
|
|
101
103
|
'import-zones': importZones,
|