@fdhl/oxlint-config 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammad Fadhil
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # `@fdhl/oxlint-config`
2
+
3
+ An opinionated, production-ready [Oxlint](https://oxc.rs/docs/guide/usage/linter) configuration for TypeScript and React projects. Requires `oxlint >= 1.51.0`.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ pnpm add -D @fdhl/oxlint-config oxlint
9
+ # or
10
+ npm install --save-dev @fdhl/oxlint-config oxlint
11
+ ```
12
+
13
+ Create `oxlint.config.js` in your project root:
14
+
15
+ ```js
16
+ import config from "@fdhl/oxlint-config";
17
+
18
+ export default config;
19
+ ```
20
+
21
+ Run the linter:
22
+
23
+ ```bash
24
+ npx oxlint .
25
+ ```
26
+
27
+ ## What's Included
28
+
29
+ ### Oxlint Native Plugins
30
+
31
+ | Plugin | Purpose |
32
+ | ------------ | ------------------------------- |
33
+ | `typescript` | TypeScript-specific rules |
34
+ | `unicorn` | Modern JS best practices |
35
+ | `react` | React and React DOM rules |
36
+ | `node` | Node.js best practices |
37
+ | `import` | Import consistency and ordering |
38
+
39
+ ### JS Plugins (ESLint-compatible, bridged via oxlint)
40
+
41
+ | Plugin | Purpose |
42
+ | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
43
+ | [`eslint-plugin-perfectionist`](https://perfectionist.dev) | Sorted imports, exports, named items |
44
+ | [`eslint-plugin-react-dom`](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) | React DOM-specific rules |
45
+ | [`eslint-plugin-react-hooks`](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks) | Rules of hooks, exhaustive deps |
46
+ | [`eslint-plugin-unused-imports`](https://github.com/sweepline/eslint-plugin-unused-imports) | Auto-remove unused imports and vars |
47
+ | [`eslint-plugin-no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests) | Prevent `.only` in test files |
48
+
49
+ ## Design Principles
50
+
51
+ 1. **Explicit Opt-in Rules** — Oxlint's `correctness` category is disabled; only hand-picked rules are enabled, so you know exactly what's enforced
52
+ 2. **TypeScript-aware** — Bans `@ts-ignore`, prevents unsafe type patterns, enforces `prefer-as-const`
53
+ 3. **Modern JS** — ES2024+, prefers `at()`, `includes()`, `structuredClone()`, node protocol imports
54
+ 4. **React Best Practices** — Blocks legacy APIs (`findDOMNode`, `dangerouslySetInnerHTML`), enforces hooks rules
55
+ 5. **Import Hygiene** — Sorted imports/exports, no duplicates, unused imports auto-removed
56
+ 6. **Developer UX** — Blocks `@nocommit` tags and `.only` tests from reaching production
57
+
58
+ ## VS Code Setup
59
+
60
+ Install the [Oxlint VS Code extension](https://marketplace.visualstudio.com/items?itemName=oxc.oxc-vscode), then add to `.vscode/settings.json`:
61
+
62
+ ```json
63
+ {
64
+ "oxc.enable": true
65
+ }
66
+ ```
67
+
68
+ ## License
69
+
70
+ MIT
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const config: import("oxlint").OxlintConfig;
2
+
3
+ export default config;
package/index.js ADDED
@@ -0,0 +1,165 @@
1
+ import { defineConfig } from 'oxlint';
2
+
3
+ import { nodeConfig } from './node';
4
+ import { perfectionistConfig } from './perfectionist';
5
+ import { reactConfig } from './react';
6
+ import { typescriptConfig } from './typescript';
7
+ import { unicornConfig } from './unicorn';
8
+
9
+ export const config = defineConfig({
10
+ plugins: ['typescript', 'unicorn', 'react', 'node', 'import'],
11
+ sortImports: {
12
+ order: 'asc',
13
+ type: 'natural'
14
+ },
15
+ jsPlugins: [
16
+ 'eslint-plugin-perfectionist',
17
+ 'eslint-plugin-react-dom',
18
+ 'eslint-plugin-no-only-tests',
19
+ 'eslint-plugin-unused-imports'
20
+ ],
21
+ categories: {
22
+ correctness: 'off'
23
+ },
24
+ env: {
25
+ builtin: true,
26
+ es2024: true,
27
+ browser: true,
28
+ node: true
29
+ },
30
+ rules: {
31
+ ...nodeConfig,
32
+ ...perfectionistConfig,
33
+ ...reactConfig,
34
+ ...typescriptConfig,
35
+ ...unicornConfig,
36
+ 'constructor-super': 'error',
37
+ 'for-direction': 'error',
38
+ 'no-async-promise-executor': 'error',
39
+ 'no-case-declarations': 'error',
40
+ 'no-class-assign': 'error',
41
+ 'no-compare-neg-zero': 'error',
42
+ 'no-cond-assign': 'error',
43
+ 'no-const-assign': 'error',
44
+ 'no-constant-binary-expression': 'error',
45
+ 'no-constant-condition': 'error',
46
+ 'no-control-regex': 'error',
47
+ 'no-debugger': 'error',
48
+ 'no-delete-var': 'error',
49
+ 'no-dupe-class-members': 'error',
50
+ 'no-dupe-else-if': 'error',
51
+ 'no-dupe-keys': 'error',
52
+ 'no-duplicate-case': 'error',
53
+ 'no-empty': 'error',
54
+ 'no-empty-character-class': 'error',
55
+ 'no-empty-pattern': 'error',
56
+ 'no-empty-static-block': 'error',
57
+ 'no-ex-assign': 'error',
58
+ 'no-extra-boolean-cast': 'error',
59
+ 'no-fallthrough': 'error',
60
+ 'no-func-assign': 'error',
61
+ 'no-global-assign': 'error',
62
+ 'no-import-assign': 'error',
63
+ 'no-invalid-regexp': 'error',
64
+ 'no-irregular-whitespace': 'error',
65
+ 'no-loss-of-precision': 'error',
66
+ 'no-misleading-character-class': 'error',
67
+ 'no-new-native-nonconstructor': 'error',
68
+ 'no-nonoctal-decimal-escape': 'error',
69
+ 'no-obj-calls': 'error',
70
+ 'no-prototype-builtins': 'error',
71
+ 'no-redeclare': [
72
+ 'error',
73
+ {
74
+ builtinGlobals: false
75
+ }
76
+ ],
77
+ 'no-regex-spaces': 'error',
78
+ 'no-self-assign': 'error',
79
+ 'no-setter-return': 'error',
80
+ 'no-shadow-restricted-names': 'error',
81
+ 'no-sparse-arrays': 'error',
82
+ 'no-this-before-super': 'error',
83
+ 'no-unexpected-multiline': 'error',
84
+ 'no-unsafe-finally': 'error',
85
+ 'no-unsafe-negation': 'error',
86
+ 'no-unsafe-optional-chaining': 'error',
87
+ 'no-unused-labels': 'error',
88
+ 'no-unused-private-class-members': 'error',
89
+ 'no-useless-backreference': 'error',
90
+ 'no-useless-catch': 'error',
91
+ 'no-useless-escape': 'error',
92
+ 'no-with': 'error',
93
+ 'require-yield': 'error',
94
+ 'use-isnan': [
95
+ 'error',
96
+ {
97
+ enforceForIndexOf: true,
98
+ enforceForSwitchCase: true
99
+ }
100
+ ],
101
+ 'valid-typeof': 'error',
102
+ curly: 'error',
103
+ 'import/consistent-type-specifier-style': ['error', 'top-level'],
104
+ 'import/first': 'error',
105
+ 'import/no-duplicates': 'error',
106
+ 'import/no-mutable-exports': 'error',
107
+ 'import/no-named-default': 'error',
108
+ 'no-console': [
109
+ 'error',
110
+ {
111
+ allow: ['warn', 'error']
112
+ }
113
+ ],
114
+ 'no-only-tests/no-only-tests': 'error',
115
+ 'no-useless-rename': 'error',
116
+ 'no-useless-return': 'error',
117
+ 'no-var': 'error',
118
+ 'no-warning-comments': [
119
+ 'error',
120
+ {
121
+ terms: ['@nocommit']
122
+ }
123
+ ],
124
+ 'prefer-const': 'error',
125
+ 'prefer-spread': 'error',
126
+ 'unused-imports/no-unused-imports': 'error',
127
+ 'unused-imports/no-unused-vars': [
128
+ 'error',
129
+ {
130
+ args: 'after-used',
131
+ argsIgnorePattern: '^_',
132
+ ignoreRestSiblings: true,
133
+ vars: 'all',
134
+ varsIgnorePattern: '^_'
135
+ }
136
+ ],
137
+ 'no-use-before-define': [
138
+ 'error',
139
+ {
140
+ classes: false,
141
+ functions: false,
142
+ variables: true
143
+ }
144
+ ]
145
+ },
146
+ overrides: [
147
+ {
148
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
149
+ rules: {
150
+ 'constructor-super': 'off',
151
+ 'no-class-assign': 'off',
152
+ 'no-dupe-class-members': 'off',
153
+ 'no-func-assign': 'off',
154
+ 'no-import-assign': 'off',
155
+ 'no-new-native-nonconstructor': 'off',
156
+ 'no-obj-calls': 'off',
157
+ 'no-redeclare': 'off',
158
+ 'no-setter-return': 'off',
159
+ 'no-unsafe-negation': 'off',
160
+ 'no-with': 'off',
161
+ 'prefer-rest-params': 'error'
162
+ }
163
+ }
164
+ ]
165
+ });
package/node.js ADDED
@@ -0,0 +1,6 @@
1
+ export const nodeConfig = {
2
+ "node/handle-callback-err": ["error", "^(err|error)$"],
3
+ "node/no-exports-assign": "error",
4
+ "node/no-new-require": "error",
5
+ "node/no-path-concat": "error",
6
+ };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@fdhl/oxlint-config",
3
+ "version": "1.0.0",
4
+ "description": "An opinionated Oxlint config for TypeScript projects",
5
+ "keywords": [
6
+ "autofix",
7
+ "config",
8
+ "defaults",
9
+ "oxlint"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Muhammad Fadhil <mail@mfadhil.me>",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/technowizard/oxlint-config.git"
16
+ },
17
+ "type": "module",
18
+ "main": "index.js",
19
+ "types": "index.d.ts",
20
+ "scripts": {
21
+ "format": "oxfmt --write .",
22
+ "lint": "oxlint ."
23
+ },
24
+ "dependencies": {
25
+ "eslint-plugin-no-only-tests": "^3.3.0",
26
+ "eslint-plugin-perfectionist": "^5.7.0",
27
+ "eslint-plugin-react-dom": "^3.0.0",
28
+ "eslint-plugin-react-hooks": "^7.0.1",
29
+ "eslint-plugin-unused-imports": "^4.4.1"
30
+ },
31
+ "devDependencies": {
32
+ "oxfmt": "^0.42.0",
33
+ "oxlint": "^1.57.0"
34
+ },
35
+ "peerDependencies": {
36
+ "oxlint": ">=1.51.0"
37
+ }
38
+ }
@@ -0,0 +1,23 @@
1
+ export const perfectionistConfig = {
2
+ "perfectionist/sort-exports": [
3
+ "error",
4
+ {
5
+ order: "asc",
6
+ type: "natural",
7
+ },
8
+ ],
9
+ "perfectionist/sort-named-exports": [
10
+ "error",
11
+ {
12
+ order: "asc",
13
+ type: "natural",
14
+ },
15
+ ],
16
+ "perfectionist/sort-named-imports": [
17
+ "error",
18
+ {
19
+ order: "asc",
20
+ type: "natural",
21
+ },
22
+ ],
23
+ };
package/react.js ADDED
@@ -0,0 +1,23 @@
1
+ export const reactConfig = {
2
+ "react/jsx-no-comment-textnodes": "warn",
3
+ "react/jsx-no-duplicate-props": "warn",
4
+ "react/no-array-index-key": "warn",
5
+ "react/no-clone-element": "warn",
6
+ "react/no-direct-mutation-state": "error",
7
+ "react/no-redundant-should-component-update": "error",
8
+ "react/no-string-refs": "error",
9
+ "react-dom/no-dangerously-set-innerhtml": "warn",
10
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
11
+ "react-dom/no-find-dom-node": "error",
12
+ "react-dom/no-flush-sync": "error",
13
+ "react-dom/no-hydrate": "error",
14
+ "react-dom/no-namespace": "error",
15
+ "react-dom/no-render": "error",
16
+ "react-dom/no-render-return-value": "error",
17
+ "react-dom/no-script-url": "warn",
18
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
19
+ "react-dom/no-use-form-state": "error",
20
+ "react-dom/no-void-elements-with-children": "error",
21
+ "react-hooks/rules-of-hooks": "error",
22
+ "react-hooks/exhaustive-deps": "warn",
23
+ };
package/typescript.js ADDED
@@ -0,0 +1,35 @@
1
+ export const typescriptConfig = {
2
+ "@typescript-eslint/ban-ts-comment": [
3
+ "error",
4
+ {
5
+ "ts-expect-error": "allow-with-description",
6
+ },
7
+ ],
8
+ "no-array-constructor": "error",
9
+ "@typescript-eslint/no-duplicate-enum-values": "error",
10
+ "@typescript-eslint/no-empty-object-type": [
11
+ "error",
12
+ {
13
+ allowInterfaces: "always",
14
+ },
15
+ ],
16
+ "@typescript-eslint/no-extra-non-null-assertion": "error",
17
+ "@typescript-eslint/no-import-type-side-effects": "error",
18
+ "@typescript-eslint/no-misused-new": "error",
19
+ "@typescript-eslint/no-non-null-asserted-optional-chain": "error",
20
+ "@typescript-eslint/no-require-imports": "error",
21
+ "@typescript-eslint/no-unnecessary-type-constraint": "error",
22
+ "@typescript-eslint/no-unsafe-declaration-merging": "error",
23
+ "@typescript-eslint/no-unsafe-function-type": "error",
24
+ "no-unused-expressions": [
25
+ "error",
26
+ {
27
+ allowShortCircuit: true,
28
+ allowTaggedTemplates: true,
29
+ allowTernary: true,
30
+ },
31
+ ],
32
+ "@typescript-eslint/no-wrapper-object-types": "error",
33
+ "@typescript-eslint/prefer-as-const": "error",
34
+ "@typescript-eslint/prefer-namespace-keyword": "error",
35
+ };
package/unicorn.js ADDED
@@ -0,0 +1,42 @@
1
+ export const unicornConfig = {
2
+ "unicorn/catch-error-name": "error",
3
+ "unicorn/consistent-empty-array-spread": "error",
4
+ "unicorn/consistent-function-scoping": "error",
5
+ "unicorn/error-message": "error",
6
+ "unicorn/escape-case": "error",
7
+ "unicorn/new-for-builtins": "error",
8
+ "unicorn/no-hex-escape": "error",
9
+ "unicorn/no-instanceof-builtins": "error",
10
+ "unicorn/no-invalid-fetch-options": "error",
11
+ "unicorn/no-magic-array-flat-depth": "error",
12
+ "unicorn/no-new-array": "error",
13
+ "unicorn/no-new-buffer": "error",
14
+ "unicorn/no-typeof-undefined": "error",
15
+ "unicorn/no-unnecessary-slice-end": "error",
16
+ "unicorn/no-useless-promise-resolve-reject": "error",
17
+ "unicorn/no-useless-spread": "error",
18
+ "unicorn/number-literal-case": "error",
19
+ "unicorn/numeric-separators-style": "error",
20
+ "unicorn/prefer-array-flat-map": "error",
21
+ "unicorn/prefer-array-index-of": "error",
22
+ "unicorn/prefer-array-some": "error",
23
+ "unicorn/prefer-at": "error",
24
+ "unicorn/prefer-dom-node-append": "error",
25
+ "unicorn/prefer-dom-node-text-content": "error",
26
+ "unicorn/prefer-includes": "error",
27
+ "unicorn/prefer-native-coercion-functions": "error",
28
+ "unicorn/prefer-node-protocol": "error",
29
+ "unicorn/prefer-number-properties": "error",
30
+ "unicorn/prefer-optional-catch-binding": "error",
31
+ "unicorn/prefer-set-size": "error",
32
+ "unicorn/prefer-string-raw": "error",
33
+ "unicorn/prefer-string-replace-all": "error",
34
+ "unicorn/prefer-string-slice": "error",
35
+ "unicorn/prefer-string-starts-ends-with": "error",
36
+ "unicorn/prefer-structured-clone": "error",
37
+ "unicorn/prefer-ternary": "error",
38
+ "unicorn/prefer-top-level-await": "error",
39
+ "unicorn/prefer-type-error": "error",
40
+ "unicorn/text-encoding-identifier-case": "error",
41
+ "unicorn/throw-new-error": "error",
42
+ };