@jandragsbaek/oxlint-plugin 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 +60 -33
- package/dist/index.mjs +449 -327
- package/dist/presets.d.mts +3 -15
- package/dist/presets.mjs +15 -20
- package/package.json +1 -1
package/dist/presets.d.mts
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
import { OxlintConfig } from "oxlint";
|
|
2
2
|
export declare const TEST_FILES: string[];
|
|
3
3
|
interface FileScope {
|
|
4
|
-
/** Globs the rules apply to, relative to the config file. */
|
|
5
4
|
readonly files: ReadonlyArray<string>;
|
|
6
|
-
/** Globs inside `files` the rules skip. Test files are always skipped. */
|
|
7
5
|
readonly excludeFiles?: ReadonlyArray<string>;
|
|
8
6
|
}
|
|
9
|
-
/** Built-in rule choices and the plugin rules that fit any TypeScript project. */
|
|
10
7
|
export declare const recommended: OxlintConfig;
|
|
11
|
-
/** Deterministic tests: no real time, no polling, no timeouts or unreasoned skips. */
|
|
12
8
|
export declare const tests: OxlintConfig;
|
|
13
|
-
/** Effect code: Effect.fn, catchTags, hoisted Schema compilers, @effect/vitest. */
|
|
14
9
|
export declare const effect: OxlintConfig;
|
|
15
|
-
/** React: strict hook and render rules, and a reason on every effect that stays. */
|
|
16
10
|
export declare const react: OxlintConfig;
|
|
17
|
-
/**
|
|
18
|
-
* Files the React Compiler compiles. The compiler owns memoization, and it caches `use*`
|
|
19
|
-
* functions only if they call a hook. Use with `react`.
|
|
20
|
-
*/
|
|
21
11
|
export declare const reactCompiler: (scope: FileScope) => OxlintConfig;
|
|
22
|
-
/** Product copy that users or agents read: no em dashes. Test files are skipped. */
|
|
23
12
|
export declare const productCopy: (scope: FileScope) => OxlintConfig;
|
|
24
|
-
/**
|
|
25
|
-
* Interface text lives in message catalogs, never inline in JSX. `message` names the
|
|
26
|
-
* project's catalogs and how to read them. Test files are skipped.
|
|
27
|
-
*/
|
|
28
13
|
export declare const uiText: (scope: FileScope & {
|
|
29
14
|
readonly message?: string;
|
|
30
15
|
}) => OxlintConfig;
|
|
16
|
+
export declare const theming: (scope: FileScope & {
|
|
17
|
+
readonly message?: string;
|
|
18
|
+
}) => OxlintConfig;
|
|
31
19
|
export {};
|
package/dist/presets.mjs
CHANGED
|
@@ -2,17 +2,17 @@ import * as NodePath from "node:path";
|
|
|
2
2
|
import * as NodeURL from "node:url";
|
|
3
3
|
// src/presets.ts
|
|
4
4
|
const here = NodeURL.fileURLToPath(import.meta.url);
|
|
5
|
-
const
|
|
5
|
+
const siblingIndexTsInSourceOrIndexMjsOnceBuilt = `index${NodePath.extname(here)}`;
|
|
6
|
+
const jsPlugins = [NodePath.join(NodePath.dirname(here), siblingIndexTsInSourceOrIndexMjsOnceBuilt)];
|
|
6
7
|
const TEST_FILES = ["**/*.{test,spec,testkit}.{ts,tsx,js,jsx,mts,cts,mjs,cjs}", "**/{test,tests,__tests__,testkit,testing,fixtures,integration}/**"];
|
|
7
|
-
const scoped = (scope, rules,
|
|
8
|
-
const excludeFiles = [...
|
|
8
|
+
const scoped = (scope, rules, testFiles = "skip") => {
|
|
9
|
+
const excludeFiles = [...testFiles === "skip" ? TEST_FILES : [], ...scope.excludeFiles ?? []];
|
|
9
10
|
return {
|
|
10
11
|
files: [...scope.files],
|
|
11
12
|
...excludeFiles.length > 0 ? { excludeFiles } : {},
|
|
12
13
|
rules
|
|
13
14
|
};
|
|
14
15
|
};
|
|
15
|
-
/** Built-in rule choices and the plugin rules that fit any TypeScript project. */
|
|
16
16
|
const recommended = {
|
|
17
17
|
plugins: [
|
|
18
18
|
"eslint",
|
|
@@ -55,14 +55,15 @@ const recommended = {
|
|
|
55
55
|
"unicorn/prefer-set-has": "off",
|
|
56
56
|
"unicorn/prefer-string-starts-ends-with": "off",
|
|
57
57
|
"unicorn/require-module-specifiers": "error",
|
|
58
|
+
"jandragsbaek/max-file-lines": "error",
|
|
59
|
+
"jandragsbaek/max-file-lines-hard": "error",
|
|
58
60
|
"jandragsbaek/namespace-node-imports": "error",
|
|
59
|
-
"jandragsbaek/no-
|
|
61
|
+
"jandragsbaek/no-explanatory-comments": "error",
|
|
60
62
|
"jandragsbaek/no-unscoped-has": "error",
|
|
61
63
|
"jandragsbaek/require-suppression-reason": "error"
|
|
62
64
|
},
|
|
63
65
|
options: { reportUnusedDisableDirectives: "error" }
|
|
64
66
|
};
|
|
65
|
-
/** Deterministic tests: no real time, no polling, no timeouts or unreasoned skips. */
|
|
66
67
|
const tests = {
|
|
67
68
|
jsPlugins,
|
|
68
69
|
rules: {
|
|
@@ -74,7 +75,6 @@ const tests = {
|
|
|
74
75
|
"jandragsbaek/no-wall-clock-in-tests": "error"
|
|
75
76
|
}
|
|
76
77
|
};
|
|
77
|
-
/** Effect code: Effect.fn, catchTags, hoisted Schema compilers, @effect/vitest. */
|
|
78
78
|
const effect = {
|
|
79
79
|
jsPlugins,
|
|
80
80
|
rules: {
|
|
@@ -88,7 +88,6 @@ const effect = {
|
|
|
88
88
|
rules: { "jandragsbaek/prefer-effect-fn": "off" }
|
|
89
89
|
}]
|
|
90
90
|
};
|
|
91
|
-
/** React: strict hook and render rules, and a reason on every effect that stays. */
|
|
92
91
|
const react = {
|
|
93
92
|
plugins: ["react"],
|
|
94
93
|
jsPlugins,
|
|
@@ -109,33 +108,29 @@ const react = {
|
|
|
109
108
|
"jandragsbaek/no-unreasoned-state-sync": "error"
|
|
110
109
|
}
|
|
111
110
|
};
|
|
112
|
-
|
|
113
|
-
* Files the React Compiler compiles. The compiler owns memoization, and it caches `use*`
|
|
114
|
-
* functions only if they call a hook. Use with `react`.
|
|
115
|
-
*/
|
|
111
|
+
const compilerMemoizesContextValues = { "react/jsx-no-constructed-context-values": "off" };
|
|
116
112
|
const reactCompiler = (scope) => ({
|
|
117
113
|
jsPlugins,
|
|
118
114
|
overrides: [scoped(scope, {
|
|
119
115
|
"react/globals": "error",
|
|
120
116
|
"react/hooks": "error",
|
|
121
|
-
|
|
117
|
+
...compilerMemoizesContextValues,
|
|
122
118
|
"react/preserve-manual-memoization": "error",
|
|
123
119
|
"react/set-state-in-render": "error",
|
|
124
120
|
"react/unsupported-syntax": "error",
|
|
125
121
|
"jandragsbaek/no-manual-memo": "error"
|
|
126
|
-
},
|
|
122
|
+
}, "check"), scoped(scope, { "jandragsbaek/no-hookless-use-function": "error" })]
|
|
127
123
|
});
|
|
128
|
-
/** Product copy that users or agents read: no em dashes. Test files are skipped. */
|
|
129
124
|
const productCopy = (scope) => ({
|
|
130
125
|
jsPlugins,
|
|
131
126
|
overrides: [scoped(scope, { "jandragsbaek/no-em-dash-copy": "error" })]
|
|
132
127
|
});
|
|
133
|
-
/**
|
|
134
|
-
* Interface text lives in message catalogs, never inline in JSX. `message` names the
|
|
135
|
-
* project's catalogs and how to read them. Test files are skipped.
|
|
136
|
-
*/
|
|
137
128
|
const uiText = (scope) => ({
|
|
138
129
|
jsPlugins,
|
|
139
130
|
overrides: [scoped(scope, { "jandragsbaek/no-untranslated-ui-text": scope.message === void 0 ? "error" : ["error", { message: scope.message }] })]
|
|
140
131
|
});
|
|
141
|
-
|
|
132
|
+
const theming = (scope) => ({
|
|
133
|
+
jsPlugins,
|
|
134
|
+
overrides: [scoped(scope, { "jandragsbaek/no-raw-color": scope.message === void 0 ? "error" : ["error", { message: scope.message }] })]
|
|
135
|
+
});
|
|
136
|
+
export { TEST_FILES, effect, productCopy, react, reactCompiler, recommended, tests, theming, uiText };
|