@imranbarbhuiya/oxc-config 0.0.1 → 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.
Files changed (69) hide show
  1. package/README.md +119 -156
  2. package/dist/api-error.d.ts +7 -2
  3. package/dist/api-error.js +6 -5
  4. package/dist/api-error.js.map +1 -1
  5. package/dist/central-icons.d.ts +7 -2
  6. package/dist/central-icons.js +6 -5
  7. package/dist/central-icons.js.map +1 -1
  8. package/dist/cli/index.d.ts +1 -0
  9. package/dist/cli/index.js +523 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/common.d.ts +8 -2
  12. package/dist/common.js +36 -52
  13. package/dist/common.js.map +1 -1
  14. package/dist/config.d.ts +8 -0
  15. package/dist/config.js +31 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/edge.d.ts +5 -2
  18. package/dist/edge.js +14 -10
  19. package/dist/edge.js.map +1 -1
  20. package/dist/i18n.d.ts +8 -2
  21. package/dist/i18n.js +6 -5
  22. package/dist/i18n.js.map +1 -1
  23. package/dist/jsdoc.d.ts +5 -2
  24. package/dist/jsdoc.js +18 -17
  25. package/dist/jsdoc.js.map +1 -1
  26. package/dist/jsx.d.ts +5 -2
  27. package/dist/jsx.js +24 -26
  28. package/dist/jsx.js.map +1 -1
  29. package/dist/module.d.ts +4 -2
  30. package/dist/module.js +6 -3
  31. package/dist/module.js.map +1 -1
  32. package/dist/native-tailwind.d.ts +7 -2
  33. package/dist/native-tailwind.js +6 -5
  34. package/dist/native-tailwind.js.map +1 -1
  35. package/dist/native.d.ts +51 -2
  36. package/dist/native.js +37 -43
  37. package/dist/native.js.map +1 -1
  38. package/dist/nest-plugin.d.ts +2 -0
  39. package/dist/nest-plugin.js +3 -0
  40. package/dist/nest.d.ts +5 -2
  41. package/dist/nest.js +7 -7
  42. package/dist/nest.js.map +1 -1
  43. package/dist/next.d.ts +4 -2
  44. package/dist/next.js +25 -25
  45. package/dist/next.js.map +1 -1
  46. package/dist/node.d.ts +8 -2
  47. package/dist/node.js +67 -74
  48. package/dist/node.js.map +1 -1
  49. package/dist/oxfmt.d.ts +13 -0
  50. package/dist/oxfmt.js +16 -0
  51. package/dist/oxfmt.js.map +1 -0
  52. package/dist/plugins/api-error.js +14 -14
  53. package/dist/plugins/api-error.js.map +1 -1
  54. package/dist/react.d.ts +14 -2
  55. package/dist/react.js +56 -58
  56. package/dist/react.js.map +1 -1
  57. package/dist/tailwind.d.ts +15 -2
  58. package/dist/tailwind.js +10 -9
  59. package/dist/tailwind.js.map +1 -1
  60. package/dist/tsdoc.d.ts +15 -2
  61. package/dist/tsdoc.js +14 -14
  62. package/dist/tsdoc.js.map +1 -1
  63. package/dist/typescript.d.ts +5 -2
  64. package/dist/typescript.js +155 -192
  65. package/dist/typescript.js.map +1 -1
  66. package/package.json +162 -178
  67. package/dist/mdx.d.ts +0 -6
  68. package/dist/mdx.js +0 -25
  69. package/dist/mdx.js.map +0 -1
package/README.md CHANGED
@@ -1,190 +1,153 @@
1
- # Mahir ESLint Config
1
+ # Mahir Oxc Config
2
2
 
3
- The ultimate ESLint shareable config. This config includes all of the ESLint rules that I use in my projects.
3
+ Opinionated shared Oxlint and Oxfmt configuration for JavaScript and TypeScript projects.
4
4
 
5
- > [!Important]
6
- > This is a highly opinionated config. It's based on my personal preferences and the way I write code.
7
- > I don't recommend using this config as is as I'll update it based on my preferences without any notice.
5
+ > [!IMPORTANT]
6
+ > This config follows my personal preferences and may change without notice.
8
7
 
9
- <div align="center">
10
- <br />
11
- <p>
12
- <a href="https://www.npmjs.com/package/eslint-config-mahir"><img src="https://img.shields.io/npm/v/eslint-config-mahir.svg?maxAge=3600" alt="npm version" /></a>
13
- <a href="https://www.npmjs.com/package/eslint-config-mahir"><img src="https://img.shields.io/npm/dw/eslint-config-mahir.svg?maxAge=3600" alt="npm downloads" /></a>
14
- </p>
15
- </div>
8
+ ## Requirements
16
9
 
17
- ## Installation
10
+ - Node.js 24
18
11
 
19
- ```bash
20
- npm install --save-dev eslint eslint-config-mahir
21
- ```
12
+ ## Quick setup
22
13
 
23
- ## Quick Setup (CLI)
24
-
25
- The easiest way to set up ESLint with this config is using the CLI:
14
+ Run the interactive CLI:
26
15
 
27
16
  ```bash
28
- npx eslint-config-mahir
17
+ npx @imranbarbhuiya/oxc-config
29
18
  ```
30
19
 
31
- This will interactively guide you through selecting a preset and options. You can also use flags:
20
+ It detects the package manager and project type, creates `oxlint.config.ts` and `oxfmt.config.ts`, adds lint and format scripts, and installs:
21
+
22
+ - `@imranbarbhuiya/oxc-config`
23
+ - `oxlint`
24
+ - `oxlint-tsgolint`
25
+ - `oxfmt`
26
+ - Any selected optional JavaScript plugins
27
+
28
+ Examples:
32
29
 
33
30
  ```bash
34
- npx eslint-config-mahir --preset nextjs --tailwind
35
- npx eslint-config-mahir -p react -y
31
+ npx @imranbarbhuiya/oxc-config --preset nextjs --tailwind
32
+ npx @imranbarbhuiya/oxc-config -p react -y
36
33
  ```
37
34
 
38
35
  Available options:
39
36
 
40
- - `-p, --preset <name>` - Preset to use (nextjs, react, node, native, library)
41
- - `-t, --tailwind` - Include Tailwind CSS support
42
- - `--no-tailwind` - Exclude Tailwind CSS support
43
- - `--i18n` / `--no-i18n` - Include/exclude next-intl i18n rules (Next.js)
44
- - `--native-tailwind` / `--no-native-tailwind` - Include/exclude React Native Tailwind className rules
45
- - `--central-icons` / `--no-central-icons` - Include/exclude central-icons barrel-import rules
46
- - `--api-error` / `--no-api-error` - Include/exclude ApiError rules for queryFn/mutationFn
47
- - `--query` / `--no-query` - Include/exclude TanStack Query ESLint rules (`@tanstack/eslint-plugin-query`)
48
- - `-y, --yes` - Skip prompts and use defaults
49
- - `--cwd <path>` - Working directory
50
- - `-h, --help` - Show help
51
-
52
- The CLI offers the `i18n`, `native-tailwind`, `central-icons`, `query`, and `api-error` options only when they are relevant to your project (for example, `i18n` for Next.js, and `query` when `@tanstack/react-query` is detected).
53
-
54
- ## Manual Usage
55
-
56
- Add in your eslint.config.js (for esm projects) or eslint.config.mjs
57
-
58
- ```js
59
- import common from 'eslint-config-mahir/common';
60
- import node from 'eslint-config-mahir/node';
61
- import module from 'eslint-config-mahir/module';
62
- import typescript from 'eslint-config-mahir/typescript';
63
- import jsx from 'eslint-config-mahir/jsx';
64
- import react from 'eslint-config-mahir/react';
65
- import next from 'eslint-config-mahir/next';
66
- import mdx from 'eslint-config-mahir/mdx';
67
- import edge from 'eslint-config-mahir/edge';
68
- import jsdoc from 'eslint-config-mahir/jsdoc';
69
- import tsdoc from 'eslint-config-mahir/tsdoc';
70
- import native from 'eslint-config-mahir/native';
71
- import tailwind from 'eslint-config-mahir/tailwind';
72
- import i18n from 'eslint-config-mahir/i18n';
73
- import nativeTailwind from 'eslint-config-mahir/native-tailwind';
74
- import centralIcons from 'eslint-config-mahir/central-icons';
75
- import apiError from 'eslint-config-mahir/api-error';
76
-
77
- export default [
78
- ...common,
79
- ...node,
80
- ...module,
81
- ...typescript,
82
- ...jsx,
83
- ...react, // when using react, you can omit jsx as it's already included with react
84
- ...next,
85
- ...mdx,
86
- ...edge,
87
- ...jsdoc,
88
- ...tsdoc, // when using tsdoc, you can omit jsdoc as it's already included with tsdoc
89
- ...native, // when using native, you can omit react as it's already included with native
90
- ...tailwind, // for projects using Tailwind CSS (requires eslint-plugin-better-tailwindcss)
91
- ...i18n, // for Next.js projects using next-intl
92
- ...nativeTailwind, // for React Native projects using Tailwind (use with native + tailwind)
93
- ...centralIcons, // for React/React Native projects using @central-icons-react* packages
94
- ...apiError, // for projects using TanStack Query — require ApiError in queryFn/mutationFn
95
- ];
96
- ```
37
+ - `-p, --preset <name>` selects `nextjs`, `react`, `node`, `native`, `library`, or `nest`
38
+ - `-t, --tailwind` / `--no-tailwind`
39
+ - `--i18n` / `--no-i18n`
40
+ - `--native-tailwind` / `--no-native-tailwind`
41
+ - `--central-icons` / `--no-central-icons`
42
+ - `--api-error` / `--no-api-error`
43
+ - `--query` / `--no-query`
44
+ - `-y, --yes` skips prompts and uses detected defaults
45
+ - `--cwd <path>` changes the target directory
46
+ - `-h, --help` shows help
97
47
 
98
- You can remove any of the configs you don't need.
48
+ The CLI offers optional features only where they apply. For example, i18n is available for Next.js, while TanStack Query support is available for React-based presets.
99
49
 
100
- `api-error` accepts `allowedErrors` (default `['ApiError', 'FormValidationError']`). That list is what you may `throw new Class(...)` or `throw Class.from(...)` inside `queryFn` / `mutationFn`. Other constructors (`new Error`) and other factories (`Other.from(...)`) are reported:
50
+ ## Manual setup
101
51
 
102
- ```js
103
- {
104
- rules: {
105
- 'mahir-api-error/require-api-error': [
106
- 'error',
107
- { allowedErrors: ['ApiError', 'FormValidationError'] },
108
- ],
109
- },
110
- }
52
+ Install the config and Oxc tools:
53
+
54
+ ```bash
55
+ npm install --save-dev @imranbarbhuiya/oxc-config oxlint oxlint-tsgolint oxfmt
111
56
  ```
112
57
 
113
- > **Note**:
114
-
115
- For typescript users, typed linting is done via `projectService`. You can learn more about it from https://typescript-eslint.io/getting-started/typed-linting/#faqs and customize it as per your need.
116
-
117
- ```js
118
- /**
119
- * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
120
- */
121
- export default [
122
- ...
123
- {
124
- languageOptions: {
125
- parserOptions: {
126
- projectService: {
127
- allowDefaultProject: [
128
- 'files-outside-tsconfig.json',
129
- ],
130
- defaultProject: 'tsconfig.json',
131
- },
132
- tsconfigRootDir: process.cwd(),
133
- },
58
+ Create `oxlint.config.ts`:
59
+
60
+ ```ts
61
+ import { defineConfig } from 'oxlint';
62
+
63
+ import common from '@imranbarbhuiya/oxc-config/common';
64
+ import module from '@imranbarbhuiya/oxc-config/module';
65
+ import node from '@imranbarbhuiya/oxc-config/node';
66
+ import typescript from '@imranbarbhuiya/oxc-config/typescript';
67
+
68
+ export default defineConfig({
69
+ extends: [common, node, typescript, module],
70
+ options: {
71
+ typeAware: true,
134
72
  },
135
- ]
73
+ });
136
74
  ```
137
75
 
138
- > **Warning**:
139
- > If you are using both `mdx` and `typescript` config, make sure add files to avoid conflicts
140
-
141
- ```js
142
- /**
143
- * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
144
- */
145
- export default [
146
- // ... other configs
147
- ...mdx.map((config) => ({
148
- files: ['**/*.mdx'],
149
- ...config,
150
- })),
151
- ...typescript.map((config) => ({
152
- files: ['**/*.tsx', '**/*.ts', '**/*.cjs', '**/*.jsx', '**/*.js'],
153
- ...config,
154
- })),
155
- // ... other configs
156
- ];
76
+ `options.typeAware` belongs at the root of the Oxlint config. It enables type-aware linting through `oxlint-tsgolint`.
77
+
78
+ Create `oxfmt.config.ts`:
79
+
80
+ ```ts
81
+ import { defineConfig } from 'oxfmt';
82
+
83
+ import config from '@imranbarbhuiya/oxc-config/oxfmt';
84
+
85
+ export default defineConfig({
86
+ ...config,
87
+ });
157
88
  ```
158
89
 
159
- ## Configs
90
+ Add scripts to `package.json`:
160
91
 
161
- This package contains eslint config for
92
+ ```json
93
+ {
94
+ "scripts": {
95
+ "lint": "oxlint --fix .",
96
+ "lint:check": "oxlint .",
97
+ "format": "oxfmt",
98
+ "format:check": "oxfmt --check"
99
+ }
100
+ }
101
+ ```
162
102
 
163
- - `common` rules common for all configs
164
- - `node` rules for nodejs projects
165
- - `module` rules for esm projects
166
- - `typescript` rules for typescript projects
167
- - `jsx` rules for jsx/tsx projects
168
- - `react` rules for react projects (this config contains all the `jsx` rules too)
169
- - `native` rules for react native projects (this config contains all the `react` rules too)
170
- - `next` rules for nextjs projects
171
- - `mdx` rules for mdx projects
172
- - `edge` rules for projects running in edge
173
- - `jsdoc` jsdoc related config
174
- - `tsdoc` tsdoc related config (this config contains all the `jsdoc` rules too)
175
- - `tailwind` rules for Tailwind CSS projects (requires `eslint-plugin-better-tailwindcss`)
103
+ ## Config fragments
104
+
105
+ - `common` contains rules shared by all projects
106
+ - `node` contains Node.js rules
107
+ - `module` contains ECMAScript module rules
108
+ - `typescript` contains TypeScript and type-aware rules
109
+ - `jsx` contains JSX rules
110
+ - `react` contains React rules and includes JSX
111
+ - `native` contains React Native rules and includes React
112
+ - `next` contains Next.js rules
113
+ - `edge` contains edge-runtime rules
114
+ - `jsdoc` contains JSDoc rules
115
+ - `tsdoc` contains TSDoc rules and includes JSDoc
116
+ - `tailwind` contains Tailwind CSS rules and requires `eslint-plugin-better-tailwindcss`
117
+ - `i18n` contains next-intl rules
118
+ - `native-tailwind` contains React Native Tailwind class-name rules
119
+ - `central-icons` prevents barrel imports from `@central-icons-react*` packages
120
+ - `api-error` requires allowed error classes in TanStack Query functions
121
+
122
+ Fragments can be combined through `defineConfig({ extends: [...] })`. Install any JavaScript plugin required by an optional fragment or third-party config.
123
+
124
+ TanStack Query can be added directly:
125
+
126
+ ```ts
127
+ import { defineConfig } from 'oxlint';
128
+
129
+ import common from '@imranbarbhuiya/oxc-config/common';
130
+ import react from '@imranbarbhuiya/oxc-config/react';
131
+
132
+ export default defineConfig({
133
+ extends: [common, react],
134
+ jsPlugins: [{ name: 'query', specifier: '@tanstack/eslint-plugin-query' }],
135
+ rules: {
136
+ 'query/exhaustive-deps': 'error',
137
+ 'query/no-rest-destructuring': 'error',
138
+ 'query/stable-query-client': 'error',
139
+ },
140
+ });
141
+ ```
176
142
 
177
- The following configs are opt-in and are offered by the CLI only when relevant to your project. They are intentionally not bundled into `next` or `native`:
143
+ ## MDX
178
144
 
179
- - `i18n` rules for Next.js projects using [`next-intl`](https://next-intl.dev) (enforces static `t()` keys and disallows passing `t` around). Use alongside `next`.
180
- - `native-tailwind` rules for React Native projects using Tailwind (forbids `flex`/`flex-col`). Use alongside `native` and `tailwind`.
181
- - `central-icons` rules for React or React Native projects using `@central-icons-react*` packages (forbids barrel imports and autofixes to direct subpath imports). Use alongside `react`, `native`, or `next`.
182
- - `api-error` rules for TanStack Query projects (requires an allowed error class instead of `Error` inside `queryFn`/`mutationFn`, including extracted handlers). Allows `new ApiError(...)` and `ApiError.from(...)`; reports other constructors and factories. Override `allowedErrors` in your ESLint config if your class names differ. Use alongside `react`, `native`, or `next`.
145
+ Oxfmt formats MDX files with the shared formatter config. Oxlint does not lint MDX, so this package does not provide an MDX lint fragment.
183
146
 
184
- ## Contributors
147
+ ## Contributors
185
148
 
186
- Thanks goes to these wonderful people:
149
+ Thanks to all contributors.
187
150
 
188
- <a href="https://github.com/imranbarbhuiya/eslint-config-mahir/graphs/contributors">
189
- <img src="https://contrib.rocks/image?repo=imranbarbhuiya/eslint-config-mahir" />
151
+ <a href="https://github.com/imranbarbhuiya/oxc-config/graphs/contributors">
152
+ <img src="https://contrib.rocks/image?repo=imranbarbhuiya/oxc-config" alt="Contributors" />
190
153
  </a>
@@ -1,6 +1,11 @@
1
- import { TSESLint } from "@typescript-eslint/utils";
2
1
  //#region src/api-error.d.ts
3
- declare const config: TSESLint.FlatConfig.ConfigArray;
2
+ declare const config: {
3
+ plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
4
+ jsPlugins: import("oxlint").ExternalPluginEntry[];
5
+ rules: {
6
+ 'mahir-api-error/require-api-error': number;
7
+ };
8
+ };
4
9
  //#endregion
5
10
  export { config as default };
6
11
  //# sourceMappingURL=api-error.d.ts.map
package/dist/api-error.js CHANGED
@@ -1,11 +1,12 @@
1
- import plugin from "./plugins/api-error.js";
1
+ import { localPlugin, nativePlugins } from "./config.js";
2
+ import { defineConfig } from "oxlint";
2
3
 
3
4
  //#region src/api-error.ts
4
- const config = [{
5
- name: "mahir/api-error",
6
- plugins: { "mahir-api-error": plugin },
5
+ const config = defineConfig({
6
+ plugins: nativePlugins,
7
+ jsPlugins: [localPlugin("mahir-api-error", "./plugins/api-error.js")],
7
8
  rules: { "mahir-api-error/require-api-error": 2 }
8
- }];
9
+ });
9
10
 
10
11
  //#endregion
11
12
  export { config as default };
@@ -1 +1 @@
1
- {"version":3,"file":"api-error.js","names":["pluginApiError"],"sources":["../src/api-error.ts"],"sourcesContent":["import pluginApiError from './plugins/api-error.js';\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nconst config: TSESLint.FlatConfig.ConfigArray = [\n\t{\n\t\tname: 'mahir/api-error',\n\t\tplugins: {\n\t\t\t'mahir-api-error': pluginApiError,\n\t\t},\n\t\trules: {\n\t\t\t'mahir-api-error/require-api-error': 2,\n\t\t},\n\t},\n];\n\nexport default config;\n"],"mappings":";;;AAIA,MAAM,SAA0C,CAC/C;CACC,MAAM;CACN,SAAS,EACR,mBAAmBA,OACpB;CACA,OAAO,EACN,qCAAqC,EACtC;AACD,CACD"}
1
+ {"version":3,"file":"api-error.js","names":[],"sources":["../src/api-error.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { localPlugin, nativePlugins } from './config.js';\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('mahir-api-error', './plugins/api-error.js')],\n\trules: {\n\t\t'mahir-api-error/require-api-error': 2,\n\t},\n});\n\nexport default config;\n"],"mappings":";;;;AAIA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,mBAAmB,wBAAwB,CAAC;CACpE,OAAO,EACN,qCAAqC,EACtC;AACD,CAAC"}
@@ -1,6 +1,11 @@
1
- import { TSESLint } from "@typescript-eslint/utils";
2
1
  //#region src/central-icons.d.ts
3
- declare const config: TSESLint.FlatConfig.ConfigArray;
2
+ declare const config: {
3
+ plugins: ("eslint" | "react" | "unicorn" | "typescript" | "oxc" | "import" | "jsdoc" | "jest" | "vitest" | "jsx-a11y" | "nextjs" | "react-perf" | "promise" | "node" | "vue")[];
4
+ jsPlugins: import("oxlint").ExternalPluginEntry[];
5
+ rules: {
6
+ 'mahir-central-icons/no-central-icons-barrel-import': number;
7
+ };
8
+ };
4
9
  //#endregion
5
10
  export { config as default };
6
11
  //# sourceMappingURL=central-icons.d.ts.map
@@ -1,11 +1,12 @@
1
- import plugin from "./plugins/central-icons.js";
1
+ import { localPlugin, nativePlugins } from "./config.js";
2
+ import { defineConfig } from "oxlint";
2
3
 
3
4
  //#region src/central-icons.ts
4
- const config = [{
5
- name: "mahir/central-icons",
6
- plugins: { "mahir-central-icons": plugin },
5
+ const config = defineConfig({
6
+ plugins: nativePlugins,
7
+ jsPlugins: [localPlugin("mahir-central-icons", "./plugins/central-icons.js")],
7
8
  rules: { "mahir-central-icons/no-central-icons-barrel-import": 2 }
8
- }];
9
+ });
9
10
 
10
11
  //#endregion
11
12
  export { config as default };
@@ -1 +1 @@
1
- {"version":3,"file":"central-icons.js","names":["pluginCentralIcons"],"sources":["../src/central-icons.ts"],"sourcesContent":["import pluginCentralIcons from './plugins/central-icons.js';\n\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nconst config: TSESLint.FlatConfig.ConfigArray = [\n\t{\n\t\tname: 'mahir/central-icons',\n\t\tplugins: {\n\t\t\t'mahir-central-icons': pluginCentralIcons,\n\t\t},\n\t\trules: {\n\t\t\t'mahir-central-icons/no-central-icons-barrel-import': 2,\n\t\t},\n\t},\n];\n\nexport default config;\n"],"mappings":";;;AAIA,MAAM,SAA0C,CAC/C;CACC,MAAM;CACN,SAAS,EACR,uBAAuBA,OACxB;CACA,OAAO,EACN,sDAAsD,EACvD;AACD,CACD"}
1
+ {"version":3,"file":"central-icons.js","names":[],"sources":["../src/central-icons.ts"],"sourcesContent":["import { defineConfig } from 'oxlint';\n\nimport { localPlugin, nativePlugins } from './config.js';\n\nconst config = defineConfig({\n\tplugins: nativePlugins,\n\tjsPlugins: [localPlugin('mahir-central-icons', './plugins/central-icons.js')],\n\trules: {\n\t\t'mahir-central-icons/no-central-icons-barrel-import': 2,\n\t},\n});\n\nexport default config;\n"],"mappings":";;;;AAIA,MAAM,SAAS,aAAa;CAC3B,SAAS;CACT,WAAW,CAAC,YAAY,uBAAuB,4BAA4B,CAAC;CAC5E,OAAO,EACN,sDAAsD,EACvD;AACD,CAAC"}
@@ -0,0 +1 @@
1
+ export { };