@siim-m/config 0.1.0 → 0.3.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 +82 -5
- package/dist/ai-guard.d.ts +5 -0
- package/dist/ai-guard.js +5 -0
- package/dist/anti-slop/effect/LICENSE-enfect +21 -0
- package/dist/anti-slop/effect/index.js +8 -0
- package/dist/anti-slop/effect/rules/no-ordie-in-service-construction.d.ts +2 -0
- package/dist/anti-slop/effect/rules/no-ordie-in-service-construction.js +117 -0
- package/dist/anti-slop/effect/rules/no-unbounded-retry.d.ts +2 -0
- package/dist/anti-slop/effect/rules/no-unbounded-retry.js +307 -0
- package/dist/anti-slop/effect/rules/require-cause-when-narrowing.d.ts +2 -0
- package/dist/anti-slop/effect/rules/require-cause-when-narrowing.js +250 -0
- package/dist/anti-slop/effect/rules/throw-in-effect-gen.d.ts +2 -0
- package/dist/anti-slop/effect/rules/throw-in-effect-gen.js +87 -0
- package/dist/anti-slop/effect/shared/effect-modules.d.ts +79 -0
- package/dist/anti-slop/effect/shared/effect-modules.js +336 -0
- package/dist/anti-slop/index.js +6 -0
- package/dist/anti-slop/rules/comments.d.ts +7 -0
- package/dist/anti-slop/rules/comments.js +376 -0
- package/dist/anti-slop/rules/no-disabled-type-assertion-rules.d.ts +2 -0
- package/dist/anti-slop/rules/no-disabled-type-assertion-rules.js +94 -0
- package/dist/anti-slop/rules/require-suppression-reason.d.ts +6 -0
- package/dist/anti-slop/rules/require-suppression-reason.js +61 -0
- package/dist/anti-slop-react/LICENSE +21 -0
- package/dist/anti-slop-react/index.d.ts +3 -0
- package/dist/anti-slop-react/index.js +14 -0
- package/dist/anti-slop-react/rules/no-hookless-use-function.d.ts +8 -0
- package/dist/anti-slop-react/rules/no-hookless-use-function.js +67 -0
- package/dist/anti-slop-react/rules/no-manual-memo.d.ts +7 -0
- package/dist/anti-slop-react/rules/no-manual-memo.js +58 -0
- package/dist/anti-slop-react/rules/require-sync-comment-for-effect.d.ts +8 -0
- package/dist/anti-slop-react/rules/require-sync-comment-for-effect.js +64 -0
- package/dist/landmines.d.ts +5 -0
- package/dist/landmines.js +5 -0
- package/dist/oxlint-react.d.ts +62 -0
- package/dist/oxlint-react.js +62 -0
- package/dist/oxlint.d.ts +41 -0
- package/dist/oxlint.js +48 -1
- package/package.json +20 -6
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disallow `useMemo`, `useCallback` and the compiler's memo directives. The React Compiler
|
|
3
|
+
* memoizes components and hooks itself, so manual memoization is noise, and a directive
|
|
4
|
+
* hides the code the compiler withheld a cache scope from. From T3 Code's rule of the same name,
|
|
5
|
+
* without its `allowMemoHooks` option.
|
|
6
|
+
*/
|
|
7
|
+
export declare const noManualMemoRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineRule } from '@oxlint/plugins';
|
|
2
|
+
const MEMO_HOOKS = new Set(['useCallback', 'useMemo']);
|
|
3
|
+
// "use no memo" and "use no forget" skip a function the compiler would bail on, which hides
|
|
4
|
+
// the bailout as much as "use memo" does.
|
|
5
|
+
const OPT_OUT_DIRECTIVES = new Set(['use no memo', 'use no forget']);
|
|
6
|
+
function memoHookName(callee) {
|
|
7
|
+
if (callee.type === 'Identifier')
|
|
8
|
+
return MEMO_HOOKS.has(callee.name) ? callee.name : undefined;
|
|
9
|
+
if (callee.type === 'MemberExpression' &&
|
|
10
|
+
!callee.computed &&
|
|
11
|
+
callee.object.type === 'Identifier' &&
|
|
12
|
+
callee.object.name === 'React' &&
|
|
13
|
+
MEMO_HOOKS.has(callee.property.name)) {
|
|
14
|
+
return callee.property.name;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Disallow `useMemo`, `useCallback` and the compiler's memo directives. The React Compiler
|
|
20
|
+
* memoizes components and hooks itself, so manual memoization is noise, and a directive
|
|
21
|
+
* hides the code the compiler withheld a cache scope from. From T3 Code's rule of the same name,
|
|
22
|
+
* without its `allowMemoHooks` option.
|
|
23
|
+
*/
|
|
24
|
+
export const noManualMemoRule = defineRule({
|
|
25
|
+
meta: {
|
|
26
|
+
type: 'suggestion',
|
|
27
|
+
docs: {
|
|
28
|
+
description: 'Disallow useMemo, useCallback and memo directives; the React Compiler memoizes components and hooks.',
|
|
29
|
+
},
|
|
30
|
+
messages: {
|
|
31
|
+
memoHook: 'Drop {{name}}: the React Compiler memoizes this. Write the plain value or function.',
|
|
32
|
+
useMemoDirective: 'Drop "use memo": restructure so the compiler caches this on its own, for example by moving plain uses of a value before the hook call that splits its scope, or by inlining the helper.',
|
|
33
|
+
optOutDirective: 'Drop "{{directive}}": fix the code the compiler cannot prove safe instead of skipping it.',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
createOnce(context) {
|
|
37
|
+
return {
|
|
38
|
+
ExpressionStatement(node) {
|
|
39
|
+
if (node.directive === 'use memo') {
|
|
40
|
+
context.report({ node, messageId: 'useMemoDirective' });
|
|
41
|
+
}
|
|
42
|
+
else if (typeof node.directive === 'string' && OPT_OUT_DIRECTIVES.has(node.directive)) {
|
|
43
|
+
context.report({
|
|
44
|
+
node,
|
|
45
|
+
messageId: 'optOutDirective',
|
|
46
|
+
data: { directive: node.directive },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
CallExpression(node) {
|
|
51
|
+
const name = memoHookName(node.callee);
|
|
52
|
+
if (name === undefined)
|
|
53
|
+
return;
|
|
54
|
+
context.report({ node: node.callee, messageId: 'memoHook', data: { name } });
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Require a `SYNC:` comment above every `useEffect`, `useLayoutEffect` and
|
|
3
|
+
* `useInsertionEffect`, naming what outside React the effect keeps in step. Most effects
|
|
4
|
+
* should be a derivation during render or an event handler instead, and the message walks
|
|
5
|
+
* through those first. Adapted from T3 Code's `no-unreasoned-state-sync`, which asks for a
|
|
6
|
+
* disable comment with a reason instead, and skips test files.
|
|
7
|
+
*/
|
|
8
|
+
export declare const requireSyncCommentForEffectRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineRule } from '@oxlint/plugins';
|
|
2
|
+
const EFFECT_HOOKS = new Set(['useEffect', 'useLayoutEffect', 'useInsertionEffect']);
|
|
3
|
+
const SYNC_COMMENT = /(?:^|[^\p{L}\p{N}_])SYNC\s*:\s*\S/u;
|
|
4
|
+
const statementKinds = new Set(['ExpressionStatement', 'ReturnStatement', 'VariableDeclaration']);
|
|
5
|
+
function isEffectHookCall(callee) {
|
|
6
|
+
if (callee.type === 'Identifier')
|
|
7
|
+
return EFFECT_HOOKS.has(callee.name);
|
|
8
|
+
return (callee.type === 'MemberExpression' && !callee.computed && EFFECT_HOOKS.has(callee.property.name));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Require a `SYNC:` comment above every `useEffect`, `useLayoutEffect` and
|
|
12
|
+
* `useInsertionEffect`, naming what outside React the effect keeps in step. Most effects
|
|
13
|
+
* should be a derivation during render or an event handler instead, and the message walks
|
|
14
|
+
* through those first. Adapted from T3 Code's `no-unreasoned-state-sync`, which asks for a
|
|
15
|
+
* disable comment with a reason instead, and skips test files.
|
|
16
|
+
*/
|
|
17
|
+
export const requireSyncCommentForEffectRule = defineRule({
|
|
18
|
+
meta: {
|
|
19
|
+
type: 'suggestion',
|
|
20
|
+
docs: {
|
|
21
|
+
description: 'Require a SYNC comment naming what outside React each effect hook keeps in step.',
|
|
22
|
+
},
|
|
23
|
+
messages: {
|
|
24
|
+
missingSyncComment: 'Stop and reconsider before keeping this effect. ' +
|
|
25
|
+
'Is it computable from props or state? Compute it during render; the compiler memoizes it. ' +
|
|
26
|
+
'Does it respond to a user action? Do it in that handler. ' +
|
|
27
|
+
'Does it reset state when a prop changes? Key the component on that prop. ' +
|
|
28
|
+
'Does it tell a parent or store that a value changed? Do it where the change happens. ' +
|
|
29
|
+
'Does it read a value from outside React? Use useSyncExternalStore or the data library. ' +
|
|
30
|
+
'An effect that sets state another effect reads is one handler or one derivation. ' +
|
|
31
|
+
'An effect is right only when it keeps something outside React in step with this component while mounted: ' +
|
|
32
|
+
'a DOM node, listener, timer, connection, third-party widget, or a resource held until unmount. ' +
|
|
33
|
+
'Moving the same logic into a ref or store to avoid this rule is not a fix. ' +
|
|
34
|
+
'If the effect does that, name what it keeps in step in a comment above it: `// SYNC: <what and why>`.',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
createOnce(context) {
|
|
38
|
+
const hasSyncCommentBefore = (node) => context.sourceCode.getCommentsBefore(node).some((c) => SYNC_COMMENT.test(c.value));
|
|
39
|
+
/**
|
|
40
|
+
* A SYNC comment before the call, before any node between it and its statement, or before
|
|
41
|
+
* the `export` that declares that statement.
|
|
42
|
+
*/
|
|
43
|
+
const hasSyncComment = (node) => {
|
|
44
|
+
let current = node;
|
|
45
|
+
while (true) {
|
|
46
|
+
if (hasSyncCommentBefore(current))
|
|
47
|
+
return true;
|
|
48
|
+
if (statementKinds.has(current.type)) {
|
|
49
|
+
return (current.parent.type === 'ExportNamedDeclaration' && hasSyncCommentBefore(current.parent));
|
|
50
|
+
}
|
|
51
|
+
if (current.parent.type === 'Program')
|
|
52
|
+
return false;
|
|
53
|
+
current = current.parent;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
CallExpression(node) {
|
|
58
|
+
if (!isEffectHookCall(node.callee) || hasSyncComment(node))
|
|
59
|
+
return;
|
|
60
|
+
context.report({ node, messageId: 'missingSyncComment' });
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React preset, for code the React Compiler compiles. Extend it after the base preset:
|
|
3
|
+
*
|
|
4
|
+
* export default defineConfig({ extends: [base, react] })
|
|
5
|
+
*
|
|
6
|
+
* The base preset's `correctness` category also turns on the react and jsx-a11y plugins'
|
|
7
|
+
* correctness rules, which include the React Compiler's checks (`react/purity`, `react/refs`,
|
|
8
|
+
* `react/set-state-in-effect` and others). The rules below come from other categories.
|
|
9
|
+
*/
|
|
10
|
+
declare const preset: {
|
|
11
|
+
plugins: ("jsx-a11y" | "react")[];
|
|
12
|
+
jsPlugins: {
|
|
13
|
+
name: string;
|
|
14
|
+
specifier: string;
|
|
15
|
+
}[];
|
|
16
|
+
rules: {
|
|
17
|
+
'anti-slop-react/no-hookless-use-function': "error";
|
|
18
|
+
'anti-slop-react/no-manual-memo': "error";
|
|
19
|
+
'anti-slop-react/require-sync-comment-for-effect': "error";
|
|
20
|
+
'react/rules-of-hooks': "error";
|
|
21
|
+
'react/rule-suppression': "error";
|
|
22
|
+
'react/capitalized-calls': "error";
|
|
23
|
+
'react/unsupported-syntax': "error";
|
|
24
|
+
'react/only-export-components': ["error", {
|
|
25
|
+
allowConstantExport: true;
|
|
26
|
+
}];
|
|
27
|
+
'react/prefer-function-component': "error";
|
|
28
|
+
'react/no-array-index-key': "error";
|
|
29
|
+
'react/hook-use-state': "error";
|
|
30
|
+
'react/display-name': "error";
|
|
31
|
+
'react/no-react-children': "error";
|
|
32
|
+
'react/no-clone-element': "error";
|
|
33
|
+
'react/button-has-type': "error";
|
|
34
|
+
'react/jsx-no-target-blank': ["error", {
|
|
35
|
+
forms: true;
|
|
36
|
+
}];
|
|
37
|
+
'react/jsx-no-script-url': "error";
|
|
38
|
+
'react/iframe-missing-sandbox': "error";
|
|
39
|
+
'react/no-danger': "error";
|
|
40
|
+
'react/checked-requires-onchange-or-readonly': "error";
|
|
41
|
+
'react/jsx-no-comment-textnodes': "error";
|
|
42
|
+
'react/no-unescaped-entities': "error";
|
|
43
|
+
'react/style-prop-object': "error";
|
|
44
|
+
'react/no-namespace': "error";
|
|
45
|
+
'react/self-closing-comp': "error";
|
|
46
|
+
'react/jsx-curly-brace-presence': "error";
|
|
47
|
+
'react/jsx-fragments': "error";
|
|
48
|
+
'react/jsx-no-useless-fragment': "error";
|
|
49
|
+
'react/jsx-pascal-case': "error";
|
|
50
|
+
};
|
|
51
|
+
overrides: {
|
|
52
|
+
files: string[];
|
|
53
|
+
rules: {
|
|
54
|
+
'typescript/strict-boolean-expressions': ["error", {
|
|
55
|
+
allowNumber: false;
|
|
56
|
+
allowNullableBoolean: true;
|
|
57
|
+
allowNullableString: true;
|
|
58
|
+
}];
|
|
59
|
+
};
|
|
60
|
+
}[];
|
|
61
|
+
};
|
|
62
|
+
export default preset;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React preset, for code the React Compiler compiles. Extend it after the base preset:
|
|
3
|
+
*
|
|
4
|
+
* export default defineConfig({ extends: [base, react] })
|
|
5
|
+
*
|
|
6
|
+
* The base preset's `correctness` category also turns on the react and jsx-a11y plugins'
|
|
7
|
+
* correctness rules, which include the React Compiler's checks (`react/purity`, `react/refs`,
|
|
8
|
+
* `react/set-state-in-effect` and others). The rules below come from other categories.
|
|
9
|
+
*/
|
|
10
|
+
const preset = {
|
|
11
|
+
plugins: ['react', 'jsx-a11y'],
|
|
12
|
+
jsPlugins: [{ name: 'anti-slop-react', specifier: '@siim-m/config/anti-slop-react' }],
|
|
13
|
+
rules: {
|
|
14
|
+
'anti-slop-react/no-hookless-use-function': 'error',
|
|
15
|
+
'anti-slop-react/no-manual-memo': 'error',
|
|
16
|
+
'anti-slop-react/require-sync-comment-for-effect': 'error',
|
|
17
|
+
// oxlint files rules-of-hooks under pedantic, so the correctness category misses it.
|
|
18
|
+
'react/rules-of-hooks': 'error',
|
|
19
|
+
// A disable comment for exhaustive-deps or rules-of-hooks makes the compiler skip the function.
|
|
20
|
+
'react/rule-suppression': 'error',
|
|
21
|
+
'react/capitalized-calls': 'error',
|
|
22
|
+
'react/unsupported-syntax': 'error',
|
|
23
|
+
// Vite's Fast Refresh keeps state only in modules that export just components.
|
|
24
|
+
'react/only-export-components': ['error', { allowConstantExport: true }],
|
|
25
|
+
'react/prefer-function-component': 'error',
|
|
26
|
+
'react/no-array-index-key': 'error',
|
|
27
|
+
'react/hook-use-state': 'error',
|
|
28
|
+
'react/display-name': 'error',
|
|
29
|
+
'react/no-react-children': 'error',
|
|
30
|
+
'react/no-clone-element': 'error',
|
|
31
|
+
'react/button-has-type': 'error',
|
|
32
|
+
'react/jsx-no-target-blank': ['error', { forms: true }],
|
|
33
|
+
'react/jsx-no-script-url': 'error',
|
|
34
|
+
'react/iframe-missing-sandbox': 'error',
|
|
35
|
+
'react/no-danger': 'error',
|
|
36
|
+
'react/checked-requires-onchange-or-readonly': 'error',
|
|
37
|
+
'react/jsx-no-comment-textnodes': 'error',
|
|
38
|
+
'react/no-unescaped-entities': 'error',
|
|
39
|
+
'react/style-prop-object': 'error',
|
|
40
|
+
'react/no-namespace': 'error',
|
|
41
|
+
'react/self-closing-comp': 'error',
|
|
42
|
+
'react/jsx-curly-brace-presence': 'error',
|
|
43
|
+
'react/jsx-fragments': 'error',
|
|
44
|
+
'react/jsx-no-useless-fragment': 'error',
|
|
45
|
+
'react/jsx-pascal-case': 'error',
|
|
46
|
+
},
|
|
47
|
+
overrides: [
|
|
48
|
+
{
|
|
49
|
+
// `{count && <p />}` renders "0". Optional booleans and strings render nothing when
|
|
50
|
+
// falsy, so they may be conditions; numbers, nullable numbers and `any` may not, in any
|
|
51
|
+
// condition in a .tsx file. Type-aware.
|
|
52
|
+
files: ['**/*.tsx'],
|
|
53
|
+
rules: {
|
|
54
|
+
'typescript/strict-boolean-expressions': [
|
|
55
|
+
'error',
|
|
56
|
+
{ allowNumber: false, allowNullableBoolean: true, allowNullableString: true },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
};
|
|
62
|
+
export default preset;
|
package/dist/oxlint.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ declare const preset: {
|
|
|
15
15
|
correctness: "error";
|
|
16
16
|
};
|
|
17
17
|
rules: {
|
|
18
|
+
'anti-slop/comments': "error";
|
|
18
19
|
'anti-slop/no-chained-type-assertions': "error";
|
|
19
20
|
'anti-slop/no-conditional-empty-object-spread': "error";
|
|
21
|
+
'anti-slop/no-disabled-type-assertion-rules': "error";
|
|
20
22
|
'anti-slop/no-known-value-widening': "error";
|
|
21
23
|
'anti-slop/no-module-mocking': "error";
|
|
22
24
|
'anti-slop/no-object-parameters': "error";
|
|
@@ -32,13 +34,52 @@ declare const preset: {
|
|
|
32
34
|
'anti-slop/require-pascal-case-namespace-imports': "error";
|
|
33
35
|
'anti-slop/require-readable-spacing': "error";
|
|
34
36
|
'anti-slop/require-safety-comment-for-type-assertion': "error";
|
|
37
|
+
'anti-slop/require-suppression-reason': "error";
|
|
35
38
|
'anti-slop-effect/no-manual-effect-error-tag': "error";
|
|
39
|
+
'anti-slop-effect/no-ordie-in-service-construction': "error";
|
|
36
40
|
'anti-slop-effect/no-service-constructor-imports': "error";
|
|
37
41
|
'anti-slop-effect/no-service-parameters': "error";
|
|
42
|
+
'anti-slop-effect/no-unbounded-retry': "error";
|
|
38
43
|
'anti-slop-effect/prefer-effect-match': "error";
|
|
44
|
+
'anti-slop-effect/require-cause-when-narrowing': "error";
|
|
45
|
+
'anti-slop-effect/throw-in-effect-gen': "error";
|
|
46
|
+
'ai-guard/no-assertionless-test': "error";
|
|
47
|
+
'ai-guard/no-placeholder-implementation': "error";
|
|
48
|
+
'ai-guard/no-silent-fallback': "error";
|
|
49
|
+
'ai-guard/no-tautological-assertion': "error";
|
|
50
|
+
'ai-guard/no-test-env-branch': "error";
|
|
51
|
+
'ai-guard/no-undeclared-import': "error";
|
|
52
|
+
'landmines/no-fixed-sleep': "error";
|
|
53
|
+
'landmines/no-flake-masking': "error";
|
|
54
|
+
'landmines/no-unsignaled-poll': "error";
|
|
55
|
+
'landmines/strict-msw': "error";
|
|
39
56
|
'oxc/no-accumulating-spread': "error";
|
|
57
|
+
eqeqeq: "error";
|
|
58
|
+
'typescript/consistent-type-imports': "error";
|
|
59
|
+
'typescript/no-explicit-any': "error";
|
|
60
|
+
'typescript/no-non-null-assertion': "error";
|
|
40
61
|
'typescript/no-floating-promises': "error";
|
|
41
62
|
'typescript/no-misused-promises': "error";
|
|
63
|
+
'typescript/no-unnecessary-type-assertion': "error";
|
|
64
|
+
'typescript/no-unnecessary-type-conversion': "error";
|
|
65
|
+
'typescript/no-unsafe-argument': "error";
|
|
66
|
+
'typescript/no-unsafe-assignment': "error";
|
|
67
|
+
'typescript/no-unsafe-call': "error";
|
|
68
|
+
'typescript/no-unsafe-member-access': "error";
|
|
69
|
+
'typescript/no-unsafe-return': "error";
|
|
70
|
+
'typescript/no-unsafe-type-assertion': "error";
|
|
71
|
+
'typescript/only-throw-error': "error";
|
|
72
|
+
'typescript/switch-exhaustiveness-check': ["error", {
|
|
73
|
+
allowDefaultCaseForExhaustiveSwitch: true;
|
|
74
|
+
considerDefaultExhaustiveForUnions: true;
|
|
75
|
+
}];
|
|
76
|
+
'typescript/use-unknown-in-catch-callback-variable': "error";
|
|
42
77
|
};
|
|
78
|
+
overrides: {
|
|
79
|
+
files: string[];
|
|
80
|
+
rules: {
|
|
81
|
+
'anti-slop-effect/throw-in-effect-gen': "off";
|
|
82
|
+
};
|
|
83
|
+
}[];
|
|
43
84
|
};
|
|
44
85
|
export default preset;
|
package/dist/oxlint.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const TEST_FILES = ['**/*.test.*', '**/*.spec.*', '**/test/**', '**/tests/**', '**/__tests__/**'];
|
|
1
2
|
/**
|
|
2
3
|
* Shared oxlint preset. Extend it from `oxlint.config.mts`:
|
|
3
4
|
*
|
|
@@ -10,11 +11,15 @@ const preset = {
|
|
|
10
11
|
jsPlugins: [
|
|
11
12
|
{ name: 'anti-slop', specifier: '@siim-m/config/anti-slop' },
|
|
12
13
|
{ name: 'anti-slop-effect', specifier: '@siim-m/config/anti-slop-effect' },
|
|
14
|
+
{ name: 'ai-guard', specifier: '@siim-m/config/ai-guard' },
|
|
15
|
+
{ name: 'landmines', specifier: '@siim-m/config/landmines' },
|
|
13
16
|
],
|
|
14
17
|
categories: { correctness: 'error' },
|
|
15
18
|
rules: {
|
|
19
|
+
'anti-slop/comments': 'error',
|
|
16
20
|
'anti-slop/no-chained-type-assertions': 'error',
|
|
17
21
|
'anti-slop/no-conditional-empty-object-spread': 'error',
|
|
22
|
+
'anti-slop/no-disabled-type-assertion-rules': 'error',
|
|
18
23
|
'anti-slop/no-known-value-widening': 'error',
|
|
19
24
|
'anti-slop/no-module-mocking': 'error',
|
|
20
25
|
'anti-slop/no-object-parameters': 'error',
|
|
@@ -30,15 +35,57 @@ const preset = {
|
|
|
30
35
|
'anti-slop/require-pascal-case-namespace-imports': 'error',
|
|
31
36
|
'anti-slop/require-readable-spacing': 'error',
|
|
32
37
|
'anti-slop/require-safety-comment-for-type-assertion': 'error',
|
|
38
|
+
'anti-slop/require-suppression-reason': 'error',
|
|
33
39
|
'anti-slop-effect/no-manual-effect-error-tag': 'error',
|
|
40
|
+
'anti-slop-effect/no-ordie-in-service-construction': 'error',
|
|
34
41
|
'anti-slop-effect/no-service-constructor-imports': 'error',
|
|
35
42
|
'anti-slop-effect/no-service-parameters': 'error',
|
|
43
|
+
'anti-slop-effect/no-unbounded-retry': 'error',
|
|
36
44
|
'anti-slop-effect/prefer-effect-match': 'error',
|
|
45
|
+
'anti-slop-effect/require-cause-when-narrowing': 'error',
|
|
46
|
+
'anti-slop-effect/throw-in-effect-gen': 'error',
|
|
47
|
+
'ai-guard/no-assertionless-test': 'error',
|
|
48
|
+
'ai-guard/no-placeholder-implementation': 'error',
|
|
49
|
+
'ai-guard/no-silent-fallback': 'error',
|
|
50
|
+
'ai-guard/no-tautological-assertion': 'error',
|
|
51
|
+
'ai-guard/no-test-env-branch': 'error',
|
|
52
|
+
'ai-guard/no-undeclared-import': 'error',
|
|
53
|
+
'landmines/no-fixed-sleep': 'error',
|
|
54
|
+
'landmines/no-flake-masking': 'error',
|
|
55
|
+
'landmines/no-unsignaled-poll': 'error',
|
|
56
|
+
'landmines/strict-msw': 'error',
|
|
37
57
|
// Spreads in reducers; anti-slop/no-reduce-accumulator-copy covers the other copies.
|
|
38
58
|
'oxc/no-accumulating-spread': 'error',
|
|
39
|
-
|
|
59
|
+
eqeqeq: 'error',
|
|
60
|
+
'typescript/consistent-type-imports': 'error',
|
|
61
|
+
'typescript/no-explicit-any': 'error',
|
|
62
|
+
'typescript/no-non-null-assertion': 'error',
|
|
63
|
+
// Type-aware: these run only with `oxlint --type-aware` and tsrs or oxlint-tsgolint installed.
|
|
40
64
|
'typescript/no-floating-promises': 'error',
|
|
41
65
|
'typescript/no-misused-promises': 'error',
|
|
66
|
+
'typescript/no-unnecessary-type-assertion': 'error',
|
|
67
|
+
'typescript/no-unnecessary-type-conversion': 'error',
|
|
68
|
+
'typescript/no-unsafe-argument': 'error',
|
|
69
|
+
'typescript/no-unsafe-assignment': 'error',
|
|
70
|
+
'typescript/no-unsafe-call': 'error',
|
|
71
|
+
'typescript/no-unsafe-member-access': 'error',
|
|
72
|
+
'typescript/no-unsafe-return': 'error',
|
|
73
|
+
'typescript/no-unsafe-type-assertion': 'error',
|
|
74
|
+
'typescript/only-throw-error': 'error',
|
|
75
|
+
'typescript/switch-exhaustiveness-check': [
|
|
76
|
+
'error',
|
|
77
|
+
{ allowDefaultCaseForExhaustiveSwitch: true, considerDefaultExhaustiveForUnions: true },
|
|
78
|
+
],
|
|
79
|
+
'typescript/use-unknown-in-catch-callback-variable': 'error',
|
|
42
80
|
},
|
|
81
|
+
overrides: [
|
|
82
|
+
{
|
|
83
|
+
files: TEST_FILES,
|
|
84
|
+
rules: {
|
|
85
|
+
// A test may throw inside Effect.gen to fail on purpose.
|
|
86
|
+
'anti-slop-effect/throw-in-effect-gen': 'off',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
43
90
|
};
|
|
44
91
|
export default preset;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siim-m/config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared oxlint, oxfmt and tsconfig settings, with the anti-slop oxlint plugins",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Shared oxlint, oxfmt and tsconfig settings, with the anti-slop oxlint plugins and a React preset",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:siim-m/config",
|
|
7
7
|
"files": [
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
"type": "module",
|
|
13
13
|
"exports": {
|
|
14
14
|
"./oxlint": "./dist/oxlint.js",
|
|
15
|
+
"./oxlint-react": "./dist/oxlint-react.js",
|
|
15
16
|
"./oxfmt": "./dist/oxfmt.js",
|
|
16
17
|
"./anti-slop": "./dist/anti-slop/index.js",
|
|
17
18
|
"./anti-slop-effect": "./dist/anti-slop/effect/index.js",
|
|
19
|
+
"./anti-slop-react": "./dist/anti-slop-react/index.js",
|
|
20
|
+
"./ai-guard": "./dist/ai-guard.js",
|
|
21
|
+
"./landmines": "./dist/landmines.js",
|
|
18
22
|
"./tsconfig.json": "./tsconfig.base.json",
|
|
19
23
|
"./reset.d.ts": "./reset.d.ts"
|
|
20
24
|
},
|
|
@@ -22,7 +26,7 @@
|
|
|
22
26
|
"access": "public"
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
25
|
-
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/anti-slop/LICENSE dist/anti-slop/ && cp src/anti-slop/vendor/eslint-stylistic/LICENSE src/anti-slop/vendor/eslint-stylistic/padding-line-options.d.ts dist/anti-slop/vendor/eslint-stylistic/",
|
|
29
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && cp src/anti-slop/LICENSE dist/anti-slop/ && cp src/anti-slop/effect/LICENSE-enfect dist/anti-slop/effect/ && cp src/anti-slop-react/LICENSE dist/anti-slop-react/ && cp src/anti-slop/vendor/eslint-stylistic/LICENSE src/anti-slop/vendor/eslint-stylistic/padding-line-options.d.ts dist/anti-slop/vendor/eslint-stylistic/",
|
|
26
30
|
"typecheck": "tsc --noEmit",
|
|
27
31
|
"test": "bun run build && node --test 'src/**/*.test.ts' 'test/*.test.ts'",
|
|
28
32
|
"format": "oxfmt",
|
|
@@ -31,21 +35,25 @@
|
|
|
31
35
|
"prepublishOnly": "bun run check"
|
|
32
36
|
},
|
|
33
37
|
"dependencies": {
|
|
38
|
+
"@interfere/landmines": "^0.1.1",
|
|
34
39
|
"@oxlint/plugins": "^1.92.0",
|
|
35
|
-
"@total-typescript/ts-reset": "^0.6.1"
|
|
40
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
41
|
+
"eslint-plugin-ai-guard": "^1.4.7"
|
|
36
42
|
},
|
|
37
43
|
"devDependencies": {
|
|
38
44
|
"@types/node": "26.6.6",
|
|
45
|
+
"@types/react": "19.3.0",
|
|
39
46
|
"oxfmt": "0.77.0",
|
|
40
47
|
"oxlint": "1.92.0",
|
|
41
|
-
"
|
|
48
|
+
"tsrs": "7.1.0-beta.tsrs3",
|
|
42
49
|
"typescript": "7.0.2"
|
|
43
50
|
},
|
|
44
51
|
"peerDependencies": {
|
|
45
52
|
"@effect/tsgo": ">=0.67.5",
|
|
46
53
|
"oxfmt": ">=0.77.0",
|
|
47
54
|
"oxlint": ">=1.92.0",
|
|
48
|
-
"oxlint-tsgolint": ">=7.0.2006"
|
|
55
|
+
"oxlint-tsgolint": ">=7.0.2006",
|
|
56
|
+
"tsrs": ">=7.1.0-beta.tsrs3"
|
|
49
57
|
},
|
|
50
58
|
"peerDependenciesMeta": {
|
|
51
59
|
"@effect/tsgo": {
|
|
@@ -56,7 +64,13 @@
|
|
|
56
64
|
},
|
|
57
65
|
"oxlint-tsgolint": {
|
|
58
66
|
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"tsrs": {
|
|
69
|
+
"optional": true
|
|
59
70
|
}
|
|
60
71
|
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": "^22.18.0 || >=24.11.0"
|
|
74
|
+
},
|
|
61
75
|
"packageManager": "bun@1.4.4"
|
|
62
76
|
}
|