@jandragsbaek/oxlint-plugin 0.0.0-stage → 0.1.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.
@@ -0,0 +1,31 @@
1
+ import { OxlintConfig } from "oxlint";
2
+ export declare const TEST_FILES: string[];
3
+ interface FileScope {
4
+ /** Globs the rules apply to, relative to the config file. */
5
+ readonly files: ReadonlyArray<string>;
6
+ /** Globs inside `files` the rules skip. Test files are always skipped. */
7
+ readonly excludeFiles?: ReadonlyArray<string>;
8
+ }
9
+ /** Built-in rule choices and the plugin rules that fit any TypeScript project. */
10
+ export declare const recommended: OxlintConfig;
11
+ /** Deterministic tests: no real time, no polling, no timeouts or unreasoned skips. */
12
+ export declare const tests: OxlintConfig;
13
+ /** Effect code: Effect.fn, catchTags, hoisted Schema compilers, @effect/vitest. */
14
+ export declare const effect: OxlintConfig;
15
+ /** React: strict hook and render rules, and a reason on every effect that stays. */
16
+ 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
+ export declare const reactCompiler: (scope: FileScope) => OxlintConfig;
22
+ /** Product copy that users or agents read: no em dashes. Test files are skipped. */
23
+ 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
+ export declare const uiText: (scope: FileScope & {
29
+ readonly message?: string;
30
+ }) => OxlintConfig;
31
+ export {};
@@ -0,0 +1,141 @@
1
+ import * as NodePath from "node:path";
2
+ import * as NodeURL from "node:url";
3
+ // src/presets.ts
4
+ const here = NodeURL.fileURLToPath(import.meta.url);
5
+ const jsPlugins = [NodePath.join(NodePath.dirname(here), `index${NodePath.extname(here)}`)];
6
+ 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, excludeTests = true) => {
8
+ const excludeFiles = [...excludeTests ? TEST_FILES : [], ...scope.excludeFiles ?? []];
9
+ return {
10
+ files: [...scope.files],
11
+ ...excludeFiles.length > 0 ? { excludeFiles } : {},
12
+ rules
13
+ };
14
+ };
15
+ /** Built-in rule choices and the plugin rules that fit any TypeScript project. */
16
+ const recommended = {
17
+ plugins: [
18
+ "eslint",
19
+ "oxc",
20
+ "unicorn",
21
+ "typescript"
22
+ ],
23
+ jsPlugins,
24
+ categories: {
25
+ correctness: "warn",
26
+ suspicious: "warn",
27
+ perf: "warn"
28
+ },
29
+ rules: {
30
+ "eslint/no-await-in-loop": "off",
31
+ "eslint/no-control-regex": "off",
32
+ "eslint/no-empty-pattern": "error",
33
+ "eslint/no-new": "error",
34
+ "eslint/no-shadow": "off",
35
+ "eslint/no-underscore-dangle": "off",
36
+ "eslint/no-unneeded-ternary": "error",
37
+ "eslint/no-unsafe-optional-chaining": "error",
38
+ "eslint/no-unused-vars": ["error", {
39
+ argsIgnorePattern: "^_",
40
+ varsIgnorePattern: "^_",
41
+ caughtErrorsIgnorePattern: "^_"
42
+ }],
43
+ "oxc/no-accumulating-spread": "error",
44
+ "oxc/no-map-spread": "off",
45
+ "typescript/no-extraneous-class": "error",
46
+ "typescript/no-this-alias": "off",
47
+ "unicorn/consistent-function-scoping": "off",
48
+ "unicorn/no-array-reverse": "off",
49
+ "unicorn/no-array-sort": "off",
50
+ "unicorn/no-new-array": "off",
51
+ "unicorn/no-useless-fallback-in-spread": "error",
52
+ "unicorn/no-useless-spread": "error",
53
+ "unicorn/prefer-add-event-listener": "off",
54
+ "unicorn/prefer-array-find": "off",
55
+ "unicorn/prefer-set-has": "off",
56
+ "unicorn/prefer-string-starts-ends-with": "off",
57
+ "unicorn/require-module-specifiers": "error",
58
+ "jandragsbaek/namespace-node-imports": "error",
59
+ "jandragsbaek/no-low-value-comments": "error",
60
+ "jandragsbaek/no-unscoped-has": "error",
61
+ "jandragsbaek/require-suppression-reason": "error"
62
+ },
63
+ options: { reportUnusedDisableDirectives: "error" }
64
+ };
65
+ /** Deterministic tests: no real time, no polling, no timeouts or unreasoned skips. */
66
+ const tests = {
67
+ jsPlugins,
68
+ rules: {
69
+ "jandragsbaek/no-dom-test-environment": "error",
70
+ "jandragsbaek/no-polling-loop-in-tests": "error",
71
+ "jandragsbaek/no-real-time-wait-in-tests": "error",
72
+ "jandragsbaek/no-test-in-loop": "error",
73
+ "jandragsbaek/no-test-timeout-or-unreasoned-skip": "error",
74
+ "jandragsbaek/no-wall-clock-in-tests": "error"
75
+ }
76
+ };
77
+ /** Effect code: Effect.fn, catchTags, hoisted Schema compilers, @effect/vitest. */
78
+ const effect = {
79
+ jsPlugins,
80
+ rules: {
81
+ "jandragsbaek/no-inline-schema-compile": "error",
82
+ "jandragsbaek/no-manual-effect-runtime-in-tests": "error",
83
+ "jandragsbaek/prefer-catch-tags": "error",
84
+ "jandragsbaek/prefer-effect-fn": "error"
85
+ },
86
+ overrides: [{
87
+ files: TEST_FILES,
88
+ rules: { "jandragsbaek/prefer-effect-fn": "off" }
89
+ }]
90
+ };
91
+ /** React: strict hook and render rules, and a reason on every effect that stays. */
92
+ const react = {
93
+ plugins: ["react"],
94
+ jsPlugins,
95
+ rules: {
96
+ "react-hooks/exhaustive-deps": "off",
97
+ "react-in-jsx-scope": "off",
98
+ "react/capitalized-calls": "error",
99
+ "react/exhaustive-effect-dependencies": "error",
100
+ "react/immutability": "error",
101
+ "react/memo-dependencies": "error",
102
+ "react/no-array-index-key": "error",
103
+ "react/no-object-type-as-default-prop": "off",
104
+ "react/no-unstable-nested-components": "error",
105
+ "react/purity": "error",
106
+ "react/refs": "error",
107
+ "react/set-state-in-effect": "error",
108
+ "react/static-components": "error",
109
+ "jandragsbaek/no-unreasoned-state-sync": "error"
110
+ }
111
+ };
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
+ */
116
+ const reactCompiler = (scope) => ({
117
+ jsPlugins,
118
+ overrides: [scoped(scope, {
119
+ "react/globals": "error",
120
+ "react/hooks": "error",
121
+ "react/jsx-no-constructed-context-values": "off",
122
+ "react/preserve-manual-memoization": "error",
123
+ "react/set-state-in-render": "error",
124
+ "react/unsupported-syntax": "error",
125
+ "jandragsbaek/no-manual-memo": "error"
126
+ }, false), scoped(scope, { "jandragsbaek/no-hookless-use-function": "error" })]
127
+ });
128
+ /** Product copy that users or agents read: no em dashes. Test files are skipped. */
129
+ const productCopy = (scope) => ({
130
+ jsPlugins,
131
+ overrides: [scoped(scope, { "jandragsbaek/no-em-dash-copy": "error" })]
132
+ });
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
+ const uiText = (scope) => ({
138
+ jsPlugins,
139
+ overrides: [scoped(scope, { "jandragsbaek/no-untranslated-ui-text": scope.message === void 0 ? "error" : ["error", { message: scope.message }] })]
140
+ });
141
+ export { TEST_FILES, effect, productCopy, react, reactCompiler, recommended, tests, uiText };
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@jandragsbaek/oxlint-plugin",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Oxlint rules and presets for tests, Effect, React and product copy.",
5
+ "keywords": [
6
+ "effect",
7
+ "lint",
8
+ "oxlint",
9
+ "oxlint-plugin",
10
+ "react",
11
+ "react-compiler",
12
+ "vitest"
13
+ ],
14
+ "homepage": "https://github.com/jandragsbaek/oxlint-plugin#readme",
15
+ "bugs": "https://github.com/jandragsbaek/oxlint-plugin/issues",
16
+ "license": "MIT",
17
+ "author": "Jan Dragsbaek <jan@dragsbaek.tech>",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/jandragsbaek/oxlint-plugin.git"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "type": "module",
26
+ "exports": {
27
+ ".": "./dist/index.mjs",
28
+ "./presets": "./dist/presets.mjs",
29
+ "./package.json": "./package.json"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "scripts": {
36
+ "prepare": "vp config --no-agent",
37
+ "build": "vp pack",
38
+ "typecheck": "tsc --noEmit",
39
+ "test": "vp test run",
40
+ "lint": "vp lint --report-unused-disable-directives",
41
+ "fmt": "vp fmt",
42
+ "fmt:check": "vp fmt --check",
43
+ "check": "vp fmt --check && vp lint --report-unused-disable-directives && tsc --noEmit && vp test run && vp pack",
44
+ "prepublishOnly": "vp pack"
45
+ },
46
+ "devDependencies": {
47
+ "@effect/platform-node": "4.1.2",
48
+ "@effect/vitest": "4.1.2",
49
+ "@oxlint/plugins": "^1.94.0",
50
+ "@types/node": "^24.19.2",
51
+ "effect": "4.1.2",
52
+ "oxlint": "1.91.0",
53
+ "publint": "^0.3.25",
54
+ "typescript": "^7.0.2",
55
+ "vite-plus": "1.5.1",
56
+ "yaml": "^2.9.1"
57
+ },
58
+ "peerDependencies": {
59
+ "oxlint": ">=1.91.0"
60
+ },
61
+ "peerDependenciesMeta": {
62
+ "oxlint": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "engines": {
67
+ "node": "^20.19.0 || >=22.12.0"
68
+ },
69
+ "packageManager": "pnpm@12.16.1"
70
+ }