@paratco/eslint-config 2.3.1 → 3.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +186 -21
  3. package/dist/index.d.ts +20 -3588
  4. package/dist/index.js +2 -14
  5. package/dist/index.js.map +1 -0
  6. package/package.json +40 -27
  7. package/dist/configs/base.d.ts +0 -138
  8. package/dist/configs/base.d.ts.map +0 -1
  9. package/dist/configs/base.js +0 -29
  10. package/dist/configs/import.d.ts +0 -83
  11. package/dist/configs/import.d.ts.map +0 -1
  12. package/dist/configs/import.js +0 -41
  13. package/dist/configs/node.d.ts +0 -221
  14. package/dist/configs/node.d.ts.map +0 -1
  15. package/dist/configs/node.js +0 -7
  16. package/dist/configs/prettierFormatter.d.ts +0 -5
  17. package/dist/configs/prettierFormatter.d.ts.map +0 -1
  18. package/dist/configs/prettierFormatter.js +0 -3
  19. package/dist/configs/react.d.ts +0 -2934
  20. package/dist/configs/react.d.ts.map +0 -1
  21. package/dist/configs/react.js +0 -51
  22. package/dist/configs/stylisticFormatter.d.ts +0 -218
  23. package/dist/configs/stylisticFormatter.d.ts.map +0 -1
  24. package/dist/configs/stylisticFormatter.js +0 -29
  25. package/dist/index.d.ts.map +0 -1
  26. package/dist/rules/import.d.ts +0 -59
  27. package/dist/rules/import.d.ts.map +0 -1
  28. package/dist/rules/import.js +0 -139
  29. package/dist/rules/javascript.d.ts +0 -23
  30. package/dist/rules/javascript.d.ts.map +0 -1
  31. package/dist/rules/javascript.js +0 -42
  32. package/dist/rules/react.d.ts +0 -112
  33. package/dist/rules/react.d.ts.map +0 -1
  34. package/dist/rules/react.js +0 -330
  35. package/dist/rules/stylistic.d.ts +0 -208
  36. package/dist/rules/stylistic.d.ts.map +0 -1
  37. package/dist/rules/stylistic.js +0 -439
  38. package/dist/rules/typescript.d.ts +0 -96
  39. package/dist/rules/typescript.d.ts.map +0 -1
  40. package/dist/rules/typescript.js +0 -254
  41. package/dist/rules/unicorn.d.ts +0 -14
  42. package/dist/rules/unicorn.d.ts.map +0 -1
  43. package/dist/rules/unicorn.js +0 -32
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Paratco
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 CHANGED
@@ -1,47 +1,212 @@
1
1
  # `@paratco/eslint-config`
2
2
 
3
- Paratco ESLint configs
3
+ Paratco ESLint configs for JavaScript and TypeScript projects.
4
4
 
5
- - Typescript
5
+ - TypeScript
6
6
  - React (optional)
7
+ - Node.js
8
+ - Import plugin (optional)
9
+ - Stylistic or Prettier formatting
10
+
11
+ ## Installation
7
12
 
8
- ### Installation
9
13
 
10
14
  NPM:
11
15
  ```bash
12
- npm install --save-dev @paratco/eslint-config eslint prettier typescript-eslint
16
+ # prettier is optional, just use it if you want to use prettier formatting
17
+ npm install --save-dev @paratco/eslint-config eslint prettier
13
18
  ```
14
19
 
15
20
  Yarn:
16
21
  ```bash
17
- yarn add -D @paratco/eslint-config eslint prettier typescript-eslint
22
+ # prettier is optional, just use it if you want to use prettier formatting
23
+ yarn add -D @paratco/eslint-config eslint prettier
18
24
  ```
19
25
 
20
- ### Usage (Flat config):
26
+ ## Usage (ESLint Flat Config)
27
+
28
+ Create an `eslint.config.{js,mjs,ts}` file in your project root:
21
29
 
22
- Node.JS:
23
30
  ```javascript
24
- import paratcoEslintConfig from "@paratco/eslint-config";
31
+ import { createConfig } from "@paratco/eslint-config";
32
+
33
+ export default createConfig({
34
+ // Required: Specify the platform
35
+ platform: "node", // or "react"
36
+
37
+ // Required: Choose your formatting style
38
+ style: "prettier", // or "stylistic"
39
+
40
+ // Optional: Enable import plugin rules
41
+ useImport: true,
42
+
43
+ // Optional: TypeScript configuration
44
+ typescript: {
45
+ tsconfigRootDir: import.meta.dirname,
46
+ project: "./tsconfig.json"
47
+ },
48
+
49
+ // Optional: Add custom overrides
50
+ overrides: [
51
+ // Your custom ESLint configurations
52
+ ],
25
53
 
26
- export default [
27
- ...paratcoEslintConfig.node,
28
- ];
54
+ // Optional: Specify patterns to ignore
55
+ ignores: ["dist/**", "node_modules/**"]
56
+ });
29
57
  ```
30
58
 
31
- React:
59
+ ## Configuration Options
60
+
61
+ The `createConfig` function accepts an options object with the following properties:
62
+
63
+ | Option | Type | Required | Default | Description |
64
+ |--------|------|----------|---------|-------------|
65
+ | `platform` | `"node" \| "react"` | Yes | - | Specifies the platform for the ESLint configuration |
66
+ | `style` | `"stylistic" \| "prettier"` | Yes | - | Specifies the style formatter to use |
67
+ | `useImport` | `boolean` | No | `false` | Enable import plugin rules |
68
+ | `typescript` | `TypescriptOptions` | No | `undefined` | TypeScript configuration options |
69
+ | `overrides` | `Linter.Config[]` | No | `undefined` | Additional ESLint configurations to override defaults |
70
+ | `ignores` | `string[]` | No | `undefined` | Patterns to ignore |
71
+
72
+ ### TypeScript Options
73
+
74
+ | Option | Type | Required | Default | Description |
75
+ |--------|------|----------|---------|-------------|
76
+ | `tsconfigRootDir` | `string` | No | `undefined` | The root directory for TypeScript configuration |
77
+ | `project` | `string \| string[]` | No | `undefined` | Path to tsconfig.json file(s) |
78
+
79
+ ## Examples
80
+
81
+ ### Node.js Configuration
82
+
32
83
  ```javascript
33
- import paratcoEslintConfig from "@paratco/eslint-config";
84
+ import { createConfig } from "@paratco/eslint-config";
85
+
86
+ export default createConfig({
87
+ platform: "node",
88
+ style: "prettier",
89
+ typescript: {
90
+ tsconfigRootDir: import.meta.dirname,
91
+ project: "./tsconfig.json"
92
+ }
93
+ });
94
+ ```
95
+
96
+ ### React Configuration
97
+
98
+ ```javascript
99
+ import { createConfig } from "@paratco/eslint-config";
100
+
101
+ export default createConfig({
102
+ platform: "react",
103
+ style: "stylistic",
104
+ useImport: true,
105
+ typescript: {
106
+ tsconfigRootDir: import.meta.dirname,
107
+ project: "./tsconfig.json"
108
+ }
109
+ });
110
+ ```
111
+
112
+ ### JavaScript-only Configuration
113
+
114
+ ```javascript
115
+ import { createConfig } from "@paratco/eslint-config";
116
+
117
+ export default createConfig({
118
+ platform: "node",
119
+ style: "prettier"
120
+ });
121
+ ```
122
+
123
+ ## Using oxlint alongside ESLint
124
+
125
+ [oxlint](https://oxc-project.github.io/) is a fast JavaScript/TypeScript linter written in Rust that can be used alongside ESLint to improve performance and catch additional issues. This package supports using both linters together.
126
+
127
+ ### Installation
34
128
 
35
- export default [
36
- ...paratcoEslintConfig.react,
37
- ];
129
+ Install oxlint alongside ESLint:
130
+
131
+ NPM:
132
+ ```bash
133
+ npm install --save-dev --save-exact oxlint@1.7.0 eslint-plugin-oxlint@1.7.0
134
+ ```
135
+
136
+ Yarn:
137
+ ```bash
138
+ yarn add -D -E oxlint@1.7.0 eslint-plugin-oxlint@1.7.0
139
+ ```
140
+
141
+ note: Ensure you have the latest and exact version of oxlint and eslint-plugin-oxlint installed.
142
+
143
+ ### Configuration
144
+
145
+ 1. Create an `.oxlintrc.json` file with @oxlint/migrate:
146
+
147
+ ```bash
148
+ # version match with oxlint installed before
149
+ npx @oxlint/migrate@1.7.0
150
+ ```
151
+ This will generate or update your `.oxlintrc.json` file based on your ESLint configuration. The tool analyzes your ESLint config and converts compatible rules to their oxlint equivalents.
152
+
153
+ 2. Update your `package.json` scripts to run both linters (run oxlint first for performance):
154
+
155
+ ```json
156
+ {
157
+ "scripts": {
158
+ "lint": "oxlint --max-warnings=0 && eslint --max-warnings=0",
159
+ "lint:fix": "oxlint --fix && eslint --fix"
160
+ }
161
+ }
38
162
  ```
39
163
 
40
- Base (JS + TS rules):
164
+ 3. integrate oxlint with ESLint by adding the ESLint plugin to your configuration:
165
+
41
166
  ```javascript
42
- import paratcoEslintConfig from "@paratco/eslint-config";
167
+ import { createConfig } from "@paratco/eslint-config";
168
+ import oxlintPlugin from "eslint-plugin-oxlint";
169
+
170
+ export default createConfig({
171
+ platform: "node", // or "react"
172
+ style: "prettier", // or "stylistic"
173
+
174
+ // Add oxlint plugin as the LAST item in your overrides
175
+ // This ensures ESLint rules that are handled by oxlint are turned off
176
+ overrides: [
177
+ // Your other overrides go here
178
+
179
+ // eslint-plugin-oxlint must be the last config
180
+ ...oxlintPlugin.configs["flat/all"]
181
+ ]
182
+ });
183
+ ```
43
184
 
44
- export default [
45
- ...paratcoEslintConfig.base,
46
- ];
185
+ ### Running Linters
186
+
187
+ Run both linters with a single command:
188
+
189
+ ```bash
190
+ npm run lint
191
+ # or
192
+ yarn lint
47
193
  ```
194
+
195
+ Fix issues automatically when possible:
196
+
197
+ ```bash
198
+ npm run lint:fix
199
+ # or
200
+ yarn lint:fix
201
+ ```
202
+
203
+ ### Benefits of Using Both Linters
204
+
205
+ - **Performance**: oxlint is significantly faster than ESLint, especially on large codebases
206
+ - **Complementary Rules**: Each linter has unique rules that can catch different issues
207
+ - **Gradual Migration**: You can gradually migrate from ESLint to oxlint or use both permanently
208
+ - **Modern JavaScript Support**: oxlint has excellent support for modern JavaScript and TypeScript features
209
+
210
+ ## License
211
+
212
+ Licensed under [MIT License](./LICENSE)