@raidou/oxlint-config-base 0.0.1

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,2 @@
1
+ import type { OxlintConfig } from 'oxlint';
2
+ export declare const ejectRules: (config: OxlintConfig, outputPath: string) => Promise<void>;
@@ -0,0 +1,63 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { execFile } from 'node:child_process';
4
+ import path from 'node:path';
5
+ import { promisify } from 'node:util';
6
+ import { z } from 'zod';
7
+ const severitySchema = z.enum(['error', 'warn', 'off', 'deny', 'allow']);
8
+ const printedConfigSchema = z.object({
9
+ rules: z.record(z.string(), severitySchema),
10
+ });
11
+ const RULE_URL_BASE = 'https://oxc.rs/docs/guide/usage/linter/rules';
12
+ const execFileAsync = promisify(execFile);
13
+ const packageRoot = path.join(import.meta.dirname, '..');
14
+ const oxlintBin = path.join(path.dirname(createRequire(import.meta.url).resolve('oxlint/package.json')), 'bin', 'oxlint');
15
+ function getRuleUrl(ruleName) {
16
+ const [plugin, rule] = ruleName.split('/');
17
+ return rule === undefined
18
+ ? `${RULE_URL_BASE}/eslint/${plugin}.html`
19
+ : `${RULE_URL_BASE}/${plugin}/${rule}.html`;
20
+ }
21
+ function sortRules(rules) {
22
+ const sorted = {};
23
+ for (const name of Object.keys(rules).sort()) {
24
+ const rule = rules[name];
25
+ if (rule !== undefined)
26
+ sorted[name] = rule;
27
+ }
28
+ return sorted;
29
+ }
30
+ function configToJsonc({ rules, plugins, options }) {
31
+ const ruleLines = Object.entries(rules).map(([ruleName, rule]) => ` // ${getRuleUrl(ruleName)}\n "${ruleName}": ${JSON.stringify(rule)}`);
32
+ const lines = ['{', ` "plugins": ${JSON.stringify(plugins)},`];
33
+ if (options !== undefined) {
34
+ lines.push(` "options": ${JSON.stringify(options)},`);
35
+ }
36
+ lines.push(' "rules": {', ruleLines.join(',\n'), ' }', '}');
37
+ return lines.join('\n');
38
+ }
39
+ async function saveTo(outputPath, ejectedConfig) {
40
+ const dir = path.dirname(outputPath);
41
+ await mkdir(dir, { recursive: true });
42
+ await Promise.all([
43
+ writeFile(`${outputPath}.jsonc`, configToJsonc(ejectedConfig)),
44
+ writeFile(`${outputPath}.json`, JSON.stringify(ejectedConfig, null, 2)),
45
+ ]);
46
+ }
47
+ export const ejectRules = async (config, outputPath) => {
48
+ const { stdout } = await execFileAsync(oxlintBin, ['--print-config'], {
49
+ cwd: packageRoot,
50
+ encoding: 'utf8',
51
+ });
52
+ const printed = printedConfigSchema.parse(JSON.parse(stdout));
53
+ // NOTE: the printed output renames severities and flattens option tuples;
54
+ // overlay the source rules to restore the original spellings and payloads.
55
+ Object.assign(printed.rules, config.rules);
56
+ const ejectedConfig = {
57
+ plugins: config.plugins ?? [],
58
+ options: config.options,
59
+ rules: sortRules(printed.rules),
60
+ };
61
+ await saveTo(outputPath, ejectedConfig);
62
+ };
63
+ //# sourceMappingURL=eject-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eject-rules.js","sourceRoot":"","sources":["../src/eject-rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;AACxE,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,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Q,EAAE,MAAM;KACjB,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAC7D,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;IAC1C,MAAM,aAAa,GAAkB;QACnC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;KAChC,CAAA;IAED,MAAM,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;AACzC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { FormatConfig } from 'oxfmt';
2
+ declare const fmtconfig: FormatConfig;
3
+ export default fmtconfig;
@@ -0,0 +1,8 @@
1
+ const fmtconfig = {
2
+ printWidth: 80,
3
+ semi: false,
4
+ singleQuote: true,
5
+ trailingComma: 'all',
6
+ };
7
+ export default fmtconfig;
8
+ //# sourceMappingURL=fmt-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fmt-config.js","sourceRoot":"","sources":["../src/fmt-config.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAiB;IAC9B,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,KAAK;CACrB,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { type OxlintConfig } from 'oxlint';
2
+ declare const config: OxlintConfig;
3
+ export type { FormatConfig } from 'oxfmt';
4
+ export type { OxlintConfig } from 'oxlint';
5
+ export { config };
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'oxlint';
2
+ import { eslintRules } from "./rules/eslint.js";
3
+ import { reactRules } from "./rules/react.js";
4
+ import { typescriptRules } from "./rules/typescript.js";
5
+ const config = defineConfig({
6
+ plugins: ['eslint', 'unicorn', 'typescript', 'oxc', 'react', 'import'],
7
+ options: { typeAware: true },
8
+ categories: {
9
+ correctness: 'error',
10
+ },
11
+ rules: {
12
+ ...typescriptRules,
13
+ ...eslintRules,
14
+ ...reactRules,
15
+ },
16
+ });
17
+ export { config };
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,MAAM,GAAiB,YAAY,CAAC;IACxC,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;IACtE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;IAC5B,UAAU,EAAE;QACV,WAAW,EAAE,OAAO;KACrB;IACD,KAAK,EAAE;QACL,GAAG,eAAe;QAClB,GAAG,WAAW;QACd,GAAG,UAAU;KACd;CACF,CAAC,CAAA;AAIF,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { DummyRuleMap } from 'oxlint';
2
+ export declare const eslintRules: DummyRuleMap;
@@ -0,0 +1,84 @@
1
+ export const eslintRules = {
2
+ // ESLint core rules
3
+ 'for-direction': 'error',
4
+ 'guard-for-in': 'error',
5
+ 'no-async-promise-executor': 'error',
6
+ 'no-case-declarations': 'error',
7
+ 'no-compare-neg-zero': 'error',
8
+ 'no-cond-assign': 'error',
9
+ 'no-console': ['warn', { allow: ['assert', 'warn', 'error'] }],
10
+ 'no-constant-binary-expression': 'error',
11
+ 'no-constant-condition': 'error',
12
+ 'no-control-regex': 'error',
13
+ 'no-debugger': 'error',
14
+ 'no-delete-var': 'error',
15
+ 'no-dupe-else-if': 'error',
16
+ 'no-duplicate-case': 'error',
17
+ 'no-empty': 'error',
18
+ 'no-empty-character-class': 'error',
19
+ 'no-empty-pattern': 'error',
20
+ 'no-empty-static-block': 'error',
21
+ 'no-ex-assign': 'error',
22
+ 'no-extra-boolean-cast': 'error',
23
+ 'no-fallthrough': 'error',
24
+ 'no-global-assign': 'error',
25
+ 'no-invalid-regexp': 'error',
26
+ 'no-irregular-whitespace': 'error',
27
+ 'no-loss-of-precision': 'error',
28
+ 'no-misleading-character-class': 'error',
29
+ 'no-nonoctal-decimal-escape': 'error',
30
+ // `no-octal` does not exist in oxlint and is skipped.
31
+ 'no-prototype-builtins': 'error',
32
+ 'no-regex-spaces': 'error',
33
+ 'no-self-assign': 'error',
34
+ 'no-shadow-restricted-names': 'error',
35
+ 'no-sparse-arrays': 'error',
36
+ 'no-unassigned-vars': 'error',
37
+ 'no-unsafe-finally': 'error',
38
+ 'no-unsafe-optional-chaining': 'error',
39
+ 'no-unused-labels': 'error',
40
+ 'no-unused-private-class-members': 'error',
41
+ 'no-useless-assignment': 'error',
42
+ 'no-useless-backreference': 'error',
43
+ 'no-useless-catch': 'error',
44
+ 'no-useless-escape': 'error',
45
+ 'no-useless-rename': 'error',
46
+ 'no-useless-return': 'error',
47
+ 'no-var': 'error',
48
+ // One declaration per statement keeps blame and diffs scoped to a single
49
+ // variable.
50
+ 'one-var': ['error', 'never'],
51
+ 'object-shorthand': 'error',
52
+ 'prefer-const': 'error',
53
+ 'prefer-rest-params': 'error',
54
+ 'prefer-spread': 'error',
55
+ 'prefer-template': 'error',
56
+ 'preserve-caught-error': 'error',
57
+ 'require-yield': 'error',
58
+ // Approximation of `simple-import-sort/imports` documented by oxlint
59
+ // (`simple-import-sort/exports` has no equivalent and is dropped;
60
+ // `prettier/prettier` is dropped because formatting is owned by oxfmt).
61
+ 'sort-imports': 'error',
62
+ 'use-isnan': 'error',
63
+ 'valid-typeof': 'error',
64
+ // --- Correctness-category rules explicitly disabled ---
65
+ // Base eslint rules that the source preset turns off for TypeScript files
66
+ // because the TypeScript compiler / typescript-eslint equivalents cover
67
+ // them (see the ejected ts-rules.json, the source of truth).
68
+ 'constructor-super': 'off',
69
+ 'getter-return': 'off',
70
+ 'no-class-assign': 'off',
71
+ 'no-const-assign': 'off',
72
+ 'no-dupe-class-members': 'off',
73
+ 'no-dupe-keys': 'off',
74
+ 'no-func-assign': 'off',
75
+ 'no-import-assign': 'off',
76
+ 'no-new-native-nonconstructor': 'off',
77
+ 'no-obj-calls': 'off',
78
+ 'no-setter-return': 'off',
79
+ 'no-this-before-super': 'off',
80
+ 'no-unreachable': 'off',
81
+ 'no-unsafe-negation': 'off',
82
+ 'no-with': 'off',
83
+ };
84
+ //# sourceMappingURL=eslint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../src/rules/eslint.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,oBAAoB;IACpB,eAAe,EAAE,OAAO;IACxB,cAAc,EAAE,OAAO;IACvB,2BAA2B,EAAE,OAAO;IACpC,sBAAsB,EAAE,OAAO;IAC/B,qBAAqB,EAAE,OAAO;IAC9B,gBAAgB,EAAE,OAAO;IACzB,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC9D,+BAA+B,EAAE,OAAO;IACxC,uBAAuB,EAAE,OAAO;IAChC,kBAAkB,EAAE,OAAO;IAC3B,aAAa,EAAE,OAAO;IACtB,eAAe,EAAE,OAAO;IACxB,iBAAiB,EAAE,OAAO;IAC1B,mBAAmB,EAAE,OAAO;IAC5B,UAAU,EAAE,OAAO;IACnB,0BAA0B,EAAE,OAAO;I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1B,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,KAAK;IACxB,iBAAiB,EAAE,KAAK;IACxB,uBAAuB,EAAE,KAAK;IAC9B,cAAc,EAAE,KAAK;IACrB,gBAAgB,EAAE,KAAK;IACvB,kBAAkB,EAAE,KAAK;IACzB,8BAA8B,EAAE,KAAK;IACrC,cAAc,EAAE,KAAK;IACrB,kBAAkB,EAAE,KAAK;IACzB,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,SAAS,EAAE,KAAK;CACjB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { DummyRuleMap } from 'oxlint';
2
+ export declare const reactRules: DummyRuleMap;
@@ -0,0 +1,15 @@
1
+ export const reactRules = {
2
+ // --- React rules kept from the react-hooks preset ---
3
+ // `react-hooks/rules-of-hooks` (error) and `react-hooks/exhaustive-deps`
4
+ // (warn in ESLint, `react/exhaustive-deps` is correctness => error here).
5
+ 'react/rules-of-hooks': 'error',
6
+ // Deliberate opt-in: not in the source ESLint preset, but was firing via
7
+ // the previous all-categories-at-error behavior; kept intentionally.
8
+ 'react/no-array-index-key': 'error',
9
+ // oxlint-specific correctness rules with no counterpart in the ESLint
10
+ // preset (React Compiler based); disabled to keep parity with the preset.
11
+ 'react/preserve-manual-memoization': 'off',
12
+ 'react/refs': 'off',
13
+ 'react/set-state-in-effect': 'off',
14
+ };
15
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/rules/react.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,uDAAuD;IACvD,yEAAyE;IACzE,0EAA0E;IAC1E,sBAAsB,EAAE,OAAO;IAC/B,yEAAyE;IACzE,qEAAqE;IACrE,0BAA0B,EAAE,OAAO;IAEnC,sEAAsE;IACtE,0EAA0E;IAC1E,mCAAmC,EAAE,KAAK;IAC1C,YAAY,EAAE,KAAK;IACnB,2BAA2B,EAAE,KAAK;CACnC,CAAA"}
@@ -0,0 +1,2 @@
1
+ import type { DummyRuleMap } from 'oxlint';
2
+ export declare const typescriptRules: DummyRuleMap;
@@ -0,0 +1,85 @@
1
+ export const typescriptRules = {
2
+ // TypeScript rules (type-aware where applicable)
3
+ 'typescript/await-thenable': 'error',
4
+ 'typescript/ban-ts-comment': ['error', { minimumDescriptionLength: 10 }],
5
+ 'typescript/consistent-type-imports': 'error',
6
+ 'typescript/no-array-delete': 'error',
7
+ 'typescript/no-base-to-string': 'error',
8
+ 'typescript/no-confusing-void-expression': 'error',
9
+ 'typescript/no-deprecated': 'error',
10
+ 'typescript/no-duplicate-enum-values': 'error',
11
+ 'typescript/no-duplicate-type-constituents': 'error',
12
+ 'typescript/no-dynamic-delete': 'error',
13
+ 'typescript/no-explicit-any': 'error',
14
+ 'typescript/no-extra-non-null-assertion': 'error',
15
+ 'typescript/no-extraneous-class': 'error',
16
+ 'typescript/no-floating-promises': 'error',
17
+ 'typescript/no-for-in-array': 'error',
18
+ 'typescript/no-implied-eval': 'error',
19
+ 'typescript/no-import-type-side-effects': 'error',
20
+ 'typescript/no-invalid-void-type': 'error',
21
+ 'typescript/no-meaningless-void-operator': 'error',
22
+ 'typescript/no-misused-new': 'error',
23
+ 'typescript/no-misused-promises': 'error',
24
+ 'typescript/no-misused-spread': 'error',
25
+ 'typescript/no-mixed-enums': 'error',
26
+ 'typescript/no-non-null-asserted-nullish-coalescing': 'error',
27
+ 'typescript/no-non-null-asserted-optional-chain': 'error',
28
+ 'typescript/no-non-null-assertion': 'error',
29
+ 'typescript/no-redundant-type-constituents': 'error',
30
+ 'typescript/no-require-imports': 'error',
31
+ 'typescript/no-this-alias': 'error',
32
+ 'typescript/no-unnecessary-boolean-literal-compare': 'error',
33
+ 'typescript/no-unnecessary-condition': 'error',
34
+ 'typescript/no-unnecessary-template-expression': 'error',
35
+ 'typescript/no-unnecessary-type-arguments': 'error',
36
+ 'typescript/no-unnecessary-type-assertion': 'error',
37
+ 'typescript/no-unnecessary-type-constraint': 'error',
38
+ 'typescript/no-unnecessary-type-conversion': 'error',
39
+ 'typescript/no-unsafe-declaration-merging': 'error',
40
+ 'typescript/no-unsafe-enum-comparison': 'error',
41
+ 'typescript/no-unsafe-function-type': 'error',
42
+ 'typescript/no-unsafe-unary-minus': 'error',
43
+ 'typescript/no-useless-default-assignment': 'error',
44
+ 'typescript/no-wrapper-object-types': 'error',
45
+ 'typescript/only-throw-error': 'error',
46
+ 'typescript/prefer-as-const': 'error',
47
+ 'typescript/prefer-literal-enum-member': 'error',
48
+ 'typescript/prefer-namespace-keyword': 'error',
49
+ 'typescript/prefer-promise-reject-errors': 'error',
50
+ 'typescript/prefer-reduce-type-parameter': 'error',
51
+ 'typescript/prefer-return-this-type': 'error',
52
+ 'typescript/related-getter-setter-pairs': 'error',
53
+ 'typescript/restrict-plus-operands': [
54
+ 'error',
55
+ {
56
+ allowAny: false,
57
+ allowBoolean: false,
58
+ allowNullish: false,
59
+ allowNumberAndString: false,
60
+ allowRegExp: false,
61
+ },
62
+ ],
63
+ 'typescript/restrict-template-expressions': [
64
+ 'error',
65
+ {
66
+ allowNumber: true,
67
+ allowBoolean: true,
68
+ allowAny: false,
69
+ allowNullish: true,
70
+ allowRegExp: true,
71
+ },
72
+ ],
73
+ 'typescript/return-await': ['error', 'error-handling-correctness-only'],
74
+ 'typescript/triple-slash-reference': 'error',
75
+ 'typescript/unbound-method': 'error',
76
+ 'typescript/unified-signatures': 'error',
77
+ 'typescript/use-unknown-in-catch-callback-variable': 'error',
78
+ // oxlint has no `typescript/` variants for these; the core eslint rules
79
+ // cover TS syntax, so they are enabled instead.
80
+ 'no-array-constructor': 'error',
81
+ 'no-useless-constructor': 'error',
82
+ // `typescript/no-unused-vars` / `typescript/no-unused-expressions` do not
83
+ // exist in oxlint; the core correctness rules are already on by default.
84
+ };
85
+ //# sourceMappingURL=typescript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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IAC3C,0CAA0C,EAAE,OAAO;IACnD,oCAAoC,EAAE,OAAO;IAC7C,6BAA6B,EAAE,OAAO;IACtC,4BAA4B,EAAE,OAAO;IACrC,uCAAuC,EAAE,OAAO;IAChD,qCAAqC,EAAE,OAAO;IAC9C,yCAAyC,EAAE,OAAO;IAClD,yCAAyC,EAAE,OAAO;IAClD,oCAAoC,EAAE,OAAO;IAC7C,wCAAwC,EAAE,OAAO;IACjD,mCAAmC,EAAE;QACnC,OAAO;QACP;YACE,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,KAAK;YACnB,oBAAoB,EAAE,KAAK;YAC3B,WAAW,EAAE,KAAK;SACnB;KACF;IACD,0CAA0C,EAAE;QAC1C,OAAO;QACP;YACE,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,IAAI;SAClB;KACF;IACD,yBAAyB,EAAE,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACvE,mCAAmC,EAAE,OAAO;IAC5C,2BAA2B,EAAE,OAAO;IACpC,+BAA+B,EAAE,OAAO;IACxC,mDAAmD,EAAE,OAAO;IAC5D,wEAAwE;IACxE,gDAAgD;IAChD,sBAAsB,EAAE,OAAO;IAC/B,wBAAwB,EAAE,OAAO;IACjC,0EAA0E;IAC1E,yEAAyE;CAC1E,CAAA"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@raidou/oxlint-config-base",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "repository": "git@github.com:weirongxu/oxlint-config-base.git",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "type": "module",
10
+ "main": "./dist/index.js",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "test": "pnpm run test:types && pnpm run test:lint && pnpm run test:unit",
16
+ "test:types": "tsc --noEmit",
17
+ "test:lint": "oxfmt --check . && oxlint",
18
+ "test:unit": "vitest run",
19
+ "test:watch": "vitest",
20
+ "pretest": "pnpm run build",
21
+ "eject:rules": "tsx scripts/eject-rules.ts && oxfmt --write \"rules/*.json\"",
22
+ "prebuild": "pnpm run eject:rules",
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "prepublish": "pnpm run build",
25
+ "format": "oxfmt --write ."
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^22.20.3",
29
+ "dedent": "^1.7.2",
30
+ "oxfmt": "^0.68.0",
31
+ "oxlint": "^1.83.0",
32
+ "oxlint-tsgolint": "^7.0.2001",
33
+ "tsx": "^4.23.13",
34
+ "typescript": "^6.0.3",
35
+ "vitest": "^5.0.1",
36
+ "zod": "^4.6.5"
37
+ },
38
+ "peerDependencies": {
39
+ "oxfmt": "*",
40
+ "oxlint": "*",
41
+ "oxlint-tsgolint": "*"
42
+ },
43
+ "optionalDependencies": {
44
+ "zod": "^4.6.5"
45
+ },
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ }
49
+ }
package/readme.md ADDED
@@ -0,0 +1,22 @@
1
+ # Personal Oxlint rules for Typescript
2
+
3
+ ## Install
4
+
5
+ ```
6
+ npm install @raidou/oxlint-config-base oxlint oxlint-tsgolint oxfmt
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ oxlint.config.ts
12
+
13
+ ```typescript
14
+ import { config } from '@raidou/oxlint-config-base'
15
+ import { defineConfig } from 'oxlint'
16
+
17
+ export default defineConfig({
18
+ env: { builtin: true, node: true },
19
+ ignorePatterns: ['dist/**', 'node_modules/**'],
20
+ extends: [config],
21
+ })
22
+ ```