eslint-config-instant 2.4.0 → 2.6.0-next.5

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/README.MD CHANGED
@@ -1,81 +1,291 @@
1
1
  # ⚙️ eslint-config-instant
2
2
 
3
- A shareable eslint config used in projects created by Instant Commerce. The eslint config relies on several eslint plugins and implements prettier as a rule set.
3
+ A modern, shareable ESLint flat config for Instant Commerce projects. Built with ESLint v9, TypeScript ESLint v8, and bundled plugins for zero-config setup.
4
4
 
5
- ## Installation
5
+ ## Quick Start
6
6
 
7
- Start by removing any .eslintrc or .prettierrc files in your project. (**Note that eslintignore and prettierignore are still needed per project**)
7
+ ### Option 1: Interactive Setup (Recommended)
8
8
 
9
- Once done, drop the following line in your favorite terminal:
10
-
11
- For frontend:
12
9
  ```bash
13
- yarn add -D eslint-config-instant eslint eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-import eslint-import-resolver-alias eslint-plugin-react-hooks eslint-plugin-mdx prettier
10
+ npx eslint-config-instant init
14
11
  ```
15
12
 
16
- For backend:
13
+ This will guide you through setting up ESLint with interactive prompts for project type, TypeScript, aliases, and more.
14
+
15
+ ### Option 2: Manual Setup
16
+
17
17
  ```bash
18
- yarn add -D eslint eslint-config-prettier eslint-import-resolver-alias eslint-plugin-import eslint-plugin-prettier
18
+ pnpm add -D eslint-config-instant eslint
19
+ # For TypeScript projects:
20
+ pnpm add -D typescript
19
21
  ```
20
22
 
21
- Finally add this to your package.json
22
- Various available packages are:
23
+ Create `eslint.config.ts`:
23
24
 
24
- - instant
25
- For libraries/packages/etc where /react or /backend is overkill
25
+ ```typescript
26
+ import { instant } from 'eslint-config-instant';
26
27
 
27
- ```js
28
- "eslintConfig": {
29
- "extends": [
30
- "instant"
31
- ]
32
- },
28
+ export default instant({
29
+ type: 'react', // or 'backend' or 'library'
30
+ });
33
31
  ```
34
32
 
35
- - instant/react
36
- For all things frontend
33
+ That's it! All plugins are bundled - no need to install 10+ packages.
37
34
 
38
- ```js
39
- "eslintConfig": {
40
- "extends": [
41
- "instant/react"
42
- ]
43
- },
35
+ ## Presets
36
+
37
+ ### React (`type: 'react'`)
38
+
39
+ Full React/Next.js/Remix setup with:
40
+ - React & React Hooks rules
41
+ - JSX accessibility (a11y) rules
42
+ - TypeScript support
43
+ - Import ordering
44
+ - Prettier integration
45
+
46
+ ```typescript
47
+ import { instant } from 'eslint-config-instant';
48
+
49
+ export default instant({
50
+ type: 'react',
51
+ });
52
+ ```
53
+
54
+ ### Backend (`type: 'backend'`)
55
+
56
+ Node.js backend configuration with:
57
+ - Node.js best practices
58
+ - TypeScript support
59
+ - Import ordering
60
+ - Console logging rules
61
+ - Prettier integration
62
+
63
+ ```typescript
64
+ import { instant } from 'eslint-config-instant';
65
+
66
+ export default instant({
67
+ type: 'backend',
68
+ });
69
+ ```
70
+
71
+ ### Library (`type: 'library'`)
72
+
73
+ Minimal config for publishable packages:
74
+ - TypeScript support
75
+ - Import ordering
76
+ - Prettier integration
77
+
78
+ ```typescript
79
+ import { instant } from 'eslint-config-instant';
80
+
81
+ export default instant({
82
+ type: 'library',
83
+ });
84
+ ```
85
+
86
+ ## Customization
87
+
88
+ ### Path Aliases
89
+
90
+ Configure import aliases for your project:
91
+
92
+ ```typescript
93
+ import { instant } from 'eslint-config-instant';
94
+
95
+ export default instant({
96
+ type: 'react',
97
+ aliases: {
98
+ '~components': './src/components',
99
+ '~hooks': './src/hooks',
100
+ '@lib': './src/lib',
101
+ },
102
+ });
103
+ ```
104
+
105
+ **Note:** The config automatically reads `tsconfig.json` paths, so you may not need to specify aliases manually.
106
+
107
+ ### TypeScript Config
108
+
109
+ Specify custom TypeScript config path(s):
110
+
111
+ ```typescript
112
+ import { instant } from 'eslint-config-instant';
113
+
114
+ export default instant({
115
+ type: 'react',
116
+ tsconfig: './tsconfig.app.json', // or ['./tsconfig.app.json', './tsconfig.node.json']
117
+ });
118
+ ```
119
+
120
+ ### Feature Flags
121
+
122
+ Enable/disable specific rule sets:
123
+
124
+ ```typescript
125
+ import { instant } from 'eslint-config-instant';
126
+
127
+ export default instant({
128
+ type: 'react',
129
+ features: {
130
+ a11y: true, // JSX accessibility rules (default: true for react)
131
+ mdx: false, // MDX file support (default: false)
132
+ vitest: false, // Vitest rules (default: false)
133
+ },
134
+ });
135
+ ```
136
+
137
+ ### Custom Ignores
138
+
139
+ Add additional ignore patterns:
140
+
141
+ ```typescript
142
+ import { instant } from 'eslint-config-instant';
143
+
144
+ export default instant({
145
+ type: 'react',
146
+ ignores: ['**/generated/**', '**/*.generated.ts'],
147
+ });
44
148
  ```
45
149
 
46
- - instant/backend
47
- For all things backend
150
+ ### Prettier Configuration
48
151
 
49
- ```js
50
- "eslintConfig": {
51
- "extends": [
52
- "instant/backend"
152
+ The config includes `eslint-config-prettier` to disable conflicting rules. For formatting, use Prettier separately:
153
+
154
+ **Option 1: Use exported Prettier config**
155
+
156
+ Create `.prettierrc.js`:
157
+
158
+ ```javascript
159
+ import { prettierConfig } from 'eslint-config-instant/prettier';
160
+ export default prettierConfig;
161
+ ```
162
+
163
+ **Option 2: Custom Prettier config**
164
+
165
+ Create your own `.prettierrc.js` with your preferred settings.
166
+
167
+ ## VS Code Setup
168
+
169
+ 1. Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
170
+ 2. Add to your VS Code `settings.json`:
171
+
172
+ ```json
173
+ {
174
+ "editor.formatOnSave": true,
175
+ "[javascript]": {
176
+ "editor.formatOnSave": false
177
+ },
178
+ "[javascriptreact]": {
179
+ "editor.formatOnSave": false
180
+ },
181
+ "[typescript]": {
182
+ "editor.formatOnSave": false
183
+ },
184
+ "[typescriptreact]": {
185
+ "editor.formatOnSave": false
186
+ },
187
+ "editor.codeActionsOnSave": {
188
+ "source.fixAll.eslint": "explicit"
189
+ },
190
+ "eslint.validate": [
191
+ "javascript",
192
+ "javascriptreact",
193
+ "typescript",
194
+ "typescriptreact"
53
195
  ]
54
- },
55
- ```
56
-
57
- ## formatOnSave With VS Code
58
-
59
- Once you have installed the eslint-config, you probably want your editor to lint and fix for you.
60
- Here are the instructions for VS Code:
61
-
62
- 1. Install the [ESLint package](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
63
- 2. Now we need to setup some VS Code settings via `Code/File` → `Preferences` → `Settings`. It's easier to enter these settings while editing the `settings.json` file, so click the `{}` icon in the top right corner:
64
-
65
- ```js
66
- // These are all my auto-save configs
67
- "editor.formatOnSave": true,
68
- // turn it off for JS and JSX, we will do this via eslint
69
- "[javascript]": {
70
- "editor.formatOnSave": false
71
- },
72
- "[javascriptreact]": {
73
- "editor.formatOnSave": false
74
- },
75
- // tell the ESLint plugin to run on save
76
- "editor.codeActionsOnSave": {
77
- "source.fixAll": true
78
- },
79
- // Optional BUT IMPORTANT: If you have the prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already
80
- "prettier.disableLanguages": ["javascript", "javascriptreact"],
196
+ }
197
+ ```
198
+
199
+ ## Migration from v0.x
200
+
201
+ ### Before (v0.x)
202
+
203
+ ```json
204
+ // package.json
205
+ {
206
+ "eslintConfig": {
207
+ "extends": ["instant/react"]
208
+ }
209
+ }
210
+ ```
211
+
212
+ Required installing 10+ peer dependencies manually.
213
+
214
+ ### After (v1.x)
215
+
216
+ ```typescript
217
+ // eslint.config.ts
218
+ import { instant } from 'eslint-config-instant';
219
+
220
+ export default instant({
221
+ type: 'react',
222
+ });
223
+ ```
224
+
225
+ Only requires `eslint-config-instant` and `eslint` (and `typescript` for TS projects).
226
+
227
+ ### Migration Steps
228
+
229
+ 1. **Remove old config** - Delete `.eslintrc`, `.eslintrc.js`, or `eslintConfig` from `package.json`
230
+ 2. **Install new version** - `pnpm add -D eslint-config-instant@latest eslint`
231
+ 3. **Create `eslint.config.ts`** - Use the examples above
232
+ 4. **Remove old dependencies** - Uninstall old peer dependencies:
233
+ ```bash
234
+ pnpm remove eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-import eslint-import-resolver-alias eslint-plugin-react-hooks eslint-plugin-mdx
235
+ ```
236
+ 5. **Update scripts** - Your `package.json` scripts should still work:
237
+ ```json
238
+ {
239
+ "scripts": {
240
+ "lint": "eslint .",
241
+ "lint:fix": "eslint . --fix"
242
+ }
243
+ }
244
+ ```
245
+
246
+ ## Troubleshooting
247
+
248
+ ### "Cannot find module 'eslint-config-instant'"
249
+
250
+ Make sure you've installed the package:
251
+ ```bash
252
+ pnpm add -D eslint-config-instant eslint
253
+ ```
254
+
255
+ ### TypeScript errors in `eslint.config.ts`
256
+
257
+ Ensure you have TypeScript installed:
258
+ ```bash
259
+ pnpm add -D typescript
81
260
  ```
261
+
262
+ ### Import resolution errors
263
+
264
+ The config uses `eslint-import-resolver-typescript` which reads your `tsconfig.json` paths. Make sure your `tsconfig.json` has proper `paths` configured:
265
+
266
+ ```json
267
+ {
268
+ "compilerOptions": {
269
+ "paths": {
270
+ "~components/*": ["./src/components/*"],
271
+ "~hooks/*": ["./src/hooks/*"]
272
+ }
273
+ }
274
+ }
275
+ ```
276
+
277
+ ### ESLint not running in VS Code
278
+
279
+ 1. Ensure the ESLint extension is installed
280
+ 2. Reload VS Code window (`Cmd+Shift+P` → "Reload Window")
281
+ 3. Check the ESLint output panel for errors
282
+
283
+ ## Requirements
284
+
285
+ - Node.js >= 20
286
+ - ESLint >= 9.0.0
287
+ - TypeScript >= 5.0.0 (for TypeScript projects)
288
+
289
+ ## License
290
+
291
+ MIT
package/dist/cli.js ADDED
@@ -0,0 +1,162 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import prompts from "prompts";
7
+ var CONFIG_FILENAME_TS = "eslint.config.ts";
8
+ var CONFIG_FILENAME_JS = "eslint.config.js";
9
+ async function init() {
10
+ console.log("\n\u2699\uFE0F eslint-config-instant setup\n");
11
+ const existingConfig = [CONFIG_FILENAME_TS, CONFIG_FILENAME_JS, ".eslintrc", ".eslintrc.js", ".eslintrc.json"].find(
12
+ (f) => fs.existsSync(path.join(process.cwd(), f))
13
+ );
14
+ if (existingConfig) {
15
+ const { overwrite } = await prompts({
16
+ type: "confirm",
17
+ name: "overwrite",
18
+ message: `Found existing ${existingConfig}. Do you want to overwrite it?`,
19
+ initial: false
20
+ });
21
+ if (!overwrite) {
22
+ console.log("Aborted.");
23
+ process.exit(0);
24
+ }
25
+ }
26
+ const answers = await prompts([
27
+ {
28
+ type: "select",
29
+ name: "type",
30
+ message: "What type of project is this?",
31
+ choices: [
32
+ { title: "React / Next.js / Remix", value: "react" },
33
+ { title: "Node.js Backend", value: "backend" },
34
+ { title: "Library / Package", value: "library" }
35
+ ],
36
+ initial: 0
37
+ },
38
+ {
39
+ type: "confirm",
40
+ name: "typescript",
41
+ message: "Are you using TypeScript?",
42
+ initial: true
43
+ },
44
+ {
45
+ type: "confirm",
46
+ name: "aliases",
47
+ message: "Do you have custom import aliases (e.g., ~components, @lib)?",
48
+ initial: false
49
+ },
50
+ {
51
+ type: (prev) => prev ? "text" : null,
52
+ name: "aliasInput",
53
+ message: "Enter aliases as key=path pairs, comma-separated (e.g., ~components=./src/components,~hooks=./src/hooks):"
54
+ },
55
+ {
56
+ type: (_, values) => values.type === "react" ? "confirm" : null,
57
+ name: "a11y",
58
+ message: "Enable accessibility (a11y) rules?",
59
+ initial: true
60
+ }
61
+ ]);
62
+ if (!answers.type) {
63
+ console.log("Aborted.");
64
+ process.exit(0);
65
+ }
66
+ const options = {
67
+ type: answers.type,
68
+ typescript: answers.typescript,
69
+ aliases: answers.aliases,
70
+ aliasConfig: {},
71
+ features: {
72
+ a11y: answers.a11y ?? true
73
+ }
74
+ };
75
+ if (answers.aliasInput) {
76
+ const pairs = answers.aliasInput.split(",").map((p) => p.trim());
77
+ for (const pair of pairs) {
78
+ const [key, value] = pair.split("=").map((s) => s.trim());
79
+ if (key && value) {
80
+ options.aliasConfig[key] = value;
81
+ }
82
+ }
83
+ }
84
+ const configContent = generateConfig(options);
85
+ const filename = options.typescript ? CONFIG_FILENAME_TS : CONFIG_FILENAME_JS;
86
+ fs.writeFileSync(path.join(process.cwd(), filename), configContent);
87
+ console.log(`
88
+ \u2705 Created ${filename}`);
89
+ console.log("\nNext steps:");
90
+ console.log(" 1. Run your linter: pnpm lint");
91
+ console.log(" 2. Fix issues: pnpm lint --fix");
92
+ if (!fs.existsSync(path.join(process.cwd(), "node_modules", "eslint-config-instant"))) {
93
+ console.log("\n\u26A0\uFE0F Don't forget to install dependencies:");
94
+ console.log(" pnpm add -D eslint-config-instant eslint");
95
+ if (options.typescript) {
96
+ console.log(" pnpm add -D typescript");
97
+ }
98
+ }
99
+ console.log("");
100
+ }
101
+ function generateConfig(options) {
102
+ const { type, aliases, aliasConfig, features } = options;
103
+ const lines = [];
104
+ lines.push(`import { instant } from 'eslint-config-instant';`);
105
+ lines.push("");
106
+ lines.push("export default instant({");
107
+ lines.push(` type: '${type}',`);
108
+ if (aliases && Object.keys(aliasConfig).length > 0) {
109
+ lines.push(" aliases: {");
110
+ for (const [key, value] of Object.entries(aliasConfig)) {
111
+ lines.push(` '${key}': '${value}',`);
112
+ }
113
+ lines.push(" },");
114
+ }
115
+ if (type === "react" && features.a11y === false) {
116
+ lines.push(" features: {");
117
+ lines.push(" a11y: false,");
118
+ lines.push(" },");
119
+ }
120
+ lines.push("});");
121
+ lines.push("");
122
+ return lines.join("\n");
123
+ }
124
+ function showHelp() {
125
+ console.log(`
126
+ \u2699\uFE0F eslint-config-instant CLI
127
+
128
+ Usage:
129
+ npx eslint-config-instant init Interactive setup wizard
130
+ npx eslint-config-instant --help Show this help message
131
+
132
+ Examples:
133
+ npx eslint-config-instant init
134
+
135
+ # Or after installing:
136
+ npm exec eslint-config-instant init
137
+ `);
138
+ }
139
+ async function main() {
140
+ const args = process.argv.slice(2);
141
+ const command = args[0];
142
+ switch (command) {
143
+ case "init":
144
+ await init();
145
+ break;
146
+ case "--help":
147
+ case "-h":
148
+ case "help":
149
+ showHelp();
150
+ break;
151
+ default:
152
+ if (command) {
153
+ console.error(`Unknown command: ${command}`);
154
+ }
155
+ showHelp();
156
+ process.exit(command ? 1 : 0);
157
+ }
158
+ }
159
+ main().catch((err) => {
160
+ console.error("Error:", err.message);
161
+ process.exit(1);
162
+ });
@@ -0,0 +1,7 @@
1
+ import { F as FlatConfigArray } from '../types-Ce23S_AX.js';
2
+ import 'eslint';
3
+
4
+ declare function createBackendConfig(): FlatConfigArray;
5
+ declare const backend: FlatConfigArray;
6
+
7
+ export { backend, createBackendConfig };
@@ -0,0 +1,47 @@
1
+ // src/configs/backend.ts
2
+ import nodePlugin from "eslint-plugin-n";
3
+ import globals from "globals";
4
+ function createBackendConfig() {
5
+ return [
6
+ // Node.js plugin recommended config
7
+ nodePlugin.configs["flat/recommended"],
8
+ // Node.js environment and rules
9
+ {
10
+ languageOptions: {
11
+ globals: {
12
+ ...globals.node
13
+ }
14
+ },
15
+ rules: {
16
+ // Console logging rules for backend
17
+ "no-console": ["error", { allow: ["warn", "error", "info"] }],
18
+ // Node.js specific rules
19
+ "n/no-unsupported-features/node-builtins": "error",
20
+ "n/no-unsupported-features/es-syntax": "off",
21
+ // TypeScript handles this
22
+ "n/no-missing-import": "off",
23
+ // TypeScript handles this
24
+ "n/no-unpublished-import": "off",
25
+ // Often triggers false positives
26
+ // Prefer modern patterns
27
+ "n/prefer-promises/fs": "error",
28
+ "n/prefer-promises/dns": "error"
29
+ }
30
+ },
31
+ // Disable browser globals for backend
32
+ {
33
+ languageOptions: {
34
+ globals: {
35
+ window: "off",
36
+ document: "off"
37
+ }
38
+ }
39
+ }
40
+ ];
41
+ }
42
+ var backend = createBackendConfig();
43
+ export {
44
+ backend,
45
+ createBackendConfig
46
+ };
47
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/configs/backend.ts"],"sourcesContent":["import nodePlugin from 'eslint-plugin-n';\nimport globals from 'globals';\n\nimport type { FlatConfigArray } from '../types.js';\n\nexport function createBackendConfig(): FlatConfigArray {\n return [\n // Node.js plugin recommended config\n nodePlugin.configs['flat/recommended'],\n\n // Node.js environment and rules\n {\n languageOptions: {\n globals: {\n ...globals.node,\n },\n },\n rules: {\n // Console logging rules for backend\n 'no-console': ['error', { allow: ['warn', 'error', 'info'] }],\n\n // Node.js specific rules\n 'n/no-unsupported-features/node-builtins': 'error',\n 'n/no-unsupported-features/es-syntax': 'off', // TypeScript handles this\n 'n/no-missing-import': 'off', // TypeScript handles this\n 'n/no-unpublished-import': 'off', // Often triggers false positives\n\n // Prefer modern patterns\n 'n/prefer-promises/fs': 'error',\n 'n/prefer-promises/dns': 'error',\n },\n },\n\n // Disable browser globals for backend\n {\n languageOptions: {\n globals: {\n window: 'off',\n document: 'off',\n },\n },\n },\n ] as FlatConfigArray;\n}\n\nexport const backend = createBackendConfig();\n"],"mappings":";AAAA,OAAO,gBAAgB;AACvB,OAAO,aAAa;AAIb,SAAS,sBAAuC;AACrD,SAAO;AAAA;AAAA,IAEL,WAAW,QAAQ,kBAAkB;AAAA;AAAA,IAGrC;AAAA,MACE,iBAAiB;AAAA,QACf,SAAS;AAAA,UACP,GAAG,QAAQ;AAAA,QACb;AAAA,MACF;AAAA,MACA,OAAO;AAAA;AAAA,QAEL,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,SAAS,MAAM,EAAE,CAAC;AAAA;AAAA,QAG5D,2CAA2C;AAAA,QAC3C,uCAAuC;AAAA;AAAA,QACvC,uBAAuB;AAAA;AAAA,QACvB,2BAA2B;AAAA;AAAA;AAAA,QAG3B,wBAAwB;AAAA,QACxB,yBAAyB;AAAA,MAC3B;AAAA,IACF;AAAA;AAAA,IAGA;AAAA,MACE,iBAAiB;AAAA,QACf,SAAS;AAAA,UACP,QAAQ;AAAA,UACR,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,UAAU,oBAAoB;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { F as FlatConfigArray, I as InstantConfig } from '../types-Ce23S_AX.js';
2
+ import 'eslint';
3
+
4
+ declare function createBaseConfig(options?: InstantConfig): FlatConfigArray;
5
+ declare const base: FlatConfigArray;
6
+
7
+ export { base, createBaseConfig };
@@ -0,0 +1,93 @@
1
+ // src/configs/base.ts
2
+ import eslint from "@eslint/js";
3
+ import prettierConfig from "eslint-config-prettier";
4
+ import importX from "eslint-plugin-import-x";
5
+ import globals from "globals";
6
+ import tseslint from "typescript-eslint";
7
+ function createBaseConfig(options = {}) {
8
+ const { tsconfig = "./tsconfig.json", aliases } = options;
9
+ return tseslint.config(
10
+ // Recommended ESLint rules
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommended,
13
+ // Import plugin configuration
14
+ {
15
+ plugins: {
16
+ "import-x": importX
17
+ },
18
+ settings: {
19
+ "import-x/resolver": {
20
+ typescript: {
21
+ alwaysTryTypes: true,
22
+ project: tsconfig
23
+ },
24
+ ...aliases && {
25
+ alias: {
26
+ map: Object.entries(aliases),
27
+ extensions: [".js", ".jsx", ".ts", ".tsx"]
28
+ }
29
+ }
30
+ }
31
+ },
32
+ rules: {
33
+ // Import ordering
34
+ "import-x/order": [
35
+ "error",
36
+ {
37
+ groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
38
+ "newlines-between": "always",
39
+ alphabetize: { order: "asc", caseInsensitive: true }
40
+ }
41
+ ],
42
+ "import-x/no-duplicates": "error",
43
+ "import-x/no-unresolved": "error",
44
+ "import-x/first": "error"
45
+ }
46
+ },
47
+ // TypeScript-specific rules
48
+ {
49
+ rules: {
50
+ "@typescript-eslint/consistent-type-imports": [
51
+ "error",
52
+ { prefer: "type-imports", fixStyle: "inline-type-imports" }
53
+ ],
54
+ "@typescript-eslint/no-unused-vars": [
55
+ "error",
56
+ {
57
+ argsIgnorePattern: "^_",
58
+ varsIgnorePattern: "^_",
59
+ ignoreRestSiblings: true
60
+ }
61
+ ],
62
+ "@typescript-eslint/no-explicit-any": "warn",
63
+ "@typescript-eslint/no-empty-object-type": "off",
64
+ "@typescript-eslint/no-namespace": "off"
65
+ }
66
+ },
67
+ // General JavaScript rules
68
+ {
69
+ languageOptions: {
70
+ globals: {
71
+ ...globals.es2022
72
+ }
73
+ },
74
+ rules: {
75
+ "no-console": ["error", { allow: ["warn", "error"] }],
76
+ eqeqeq: ["error", "smart"],
77
+ "no-eval": "error",
78
+ "no-var": "error",
79
+ "prefer-const": "error",
80
+ "prefer-template": "error",
81
+ "object-shorthand": "error"
82
+ }
83
+ },
84
+ // Prettier config to disable conflicting rules (must be last)
85
+ prettierConfig
86
+ );
87
+ }
88
+ var base = createBaseConfig();
89
+ export {
90
+ base,
91
+ createBaseConfig
92
+ };
93
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/configs/base.ts"],"sourcesContent":["import eslint from '@eslint/js';\nimport prettierConfig from 'eslint-config-prettier';\nimport importX from 'eslint-plugin-import-x';\nimport globals from 'globals';\nimport tseslint from 'typescript-eslint';\n\nimport type { InstantConfig, FlatConfigArray } from '../types.js';\n\nexport function createBaseConfig(options: InstantConfig = {}): FlatConfigArray {\n const { tsconfig = './tsconfig.json', aliases } = options;\n\n return tseslint.config(\n // Recommended ESLint rules\n eslint.configs.recommended,\n\n // TypeScript ESLint recommended rules\n ...tseslint.configs.recommended,\n\n // Import plugin configuration\n {\n plugins: {\n 'import-x': importX as unknown as Record<string, unknown>,\n },\n settings: {\n 'import-x/resolver': {\n typescript: {\n alwaysTryTypes: true,\n project: tsconfig,\n },\n ...(aliases && {\n alias: {\n map: Object.entries(aliases),\n extensions: ['.js', '.jsx', '.ts', '.tsx'],\n },\n }),\n },\n },\n rules: {\n // Import ordering\n 'import-x/order': [\n 'error',\n {\n groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],\n 'newlines-between': 'always',\n alphabetize: { order: 'asc', caseInsensitive: true },\n },\n ],\n 'import-x/no-duplicates': 'error',\n 'import-x/no-unresolved': 'error',\n 'import-x/first': 'error',\n },\n },\n\n // TypeScript-specific rules\n {\n rules: {\n '@typescript-eslint/consistent-type-imports': [\n 'error',\n { prefer: 'type-imports', fixStyle: 'inline-type-imports' },\n ],\n '@typescript-eslint/no-unused-vars': [\n 'error',\n {\n argsIgnorePattern: '^_',\n varsIgnorePattern: '^_',\n ignoreRestSiblings: true,\n },\n ],\n '@typescript-eslint/no-explicit-any': 'warn',\n '@typescript-eslint/no-empty-object-type': 'off',\n '@typescript-eslint/no-namespace': 'off',\n },\n },\n\n // General JavaScript rules\n {\n languageOptions: {\n globals: {\n ...globals.es2022,\n },\n },\n rules: {\n 'no-console': ['error', { allow: ['warn', 'error'] }],\n eqeqeq: ['error', 'smart'],\n 'no-eval': 'error',\n 'no-var': 'error',\n 'prefer-const': 'error',\n 'prefer-template': 'error',\n 'object-shorthand': 'error',\n },\n },\n\n // Prettier config to disable conflicting rules (must be last)\n prettierConfig,\n ) as FlatConfigArray;\n}\n\nexport const base = createBaseConfig();\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,oBAAoB;AAC3B,OAAO,aAAa;AACpB,OAAO,aAAa;AACpB,OAAO,cAAc;AAId,SAAS,iBAAiB,UAAyB,CAAC,GAAoB;AAC7E,QAAM,EAAE,WAAW,mBAAmB,QAAQ,IAAI;AAElD,SAAO,SAAS;AAAA;AAAA,IAEd,OAAO,QAAQ;AAAA,IAGf,GAAG,SAAS,QAAQ;AAAA;AAAA,IAGpB;AAAA,MACE,SAAS;AAAA,QACP,YAAY;AAAA,MACd;AAAA,MACA,UAAU;AAAA,QACR,qBAAqB;AAAA,UACnB,YAAY;AAAA,YACV,gBAAgB;AAAA,YAChB,SAAS;AAAA,UACX;AAAA,UACA,GAAI,WAAW;AAAA,YACb,OAAO;AAAA,cACL,KAAK,OAAO,QAAQ,OAAO;AAAA,cAC3B,YAAY,CAAC,OAAO,QAAQ,OAAO,MAAM;AAAA,YAC3C;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,MACA,OAAO;AAAA;AAAA,QAEL,kBAAkB;AAAA,UAChB;AAAA,UACA;AAAA,YACE,QAAQ,CAAC,WAAW,YAAY,YAAY,UAAU,WAAW,OAAO;AAAA,YACxE,oBAAoB;AAAA,YACpB,aAAa,EAAE,OAAO,OAAO,iBAAiB,KAAK;AAAA,UACrD;AAAA,QACF;AAAA,QACA,0BAA0B;AAAA,QAC1B,0BAA0B;AAAA,QAC1B,kBAAkB;AAAA,MACpB;AAAA,IACF;AAAA;AAAA,IAGA;AAAA,MACE,OAAO;AAAA,QACL,8CAA8C;AAAA,UAC5C;AAAA,UACA,EAAE,QAAQ,gBAAgB,UAAU,sBAAsB;AAAA,QAC5D;AAAA,QACA,qCAAqC;AAAA,UACnC;AAAA,UACA;AAAA,YACE,mBAAmB;AAAA,YACnB,mBAAmB;AAAA,YACnB,oBAAoB;AAAA,UACtB;AAAA,QACF;AAAA,QACA,sCAAsC;AAAA,QACtC,2CAA2C;AAAA,QAC3C,mCAAmC;AAAA,MACrC;AAAA,IACF;AAAA;AAAA,IAGA;AAAA,MACE,iBAAiB;AAAA,QACf,SAAS;AAAA,UACP,GAAG,QAAQ;AAAA,QACb;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,OAAO,EAAE,CAAC;AAAA,QACpD,QAAQ,CAAC,SAAS,OAAO;AAAA,QACzB,WAAW;AAAA,QACX,UAAU;AAAA,QACV,gBAAgB;AAAA,QAChB,mBAAmB;AAAA,QACnB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA;AAAA,IAGA;AAAA,EACF;AACF;AAEO,IAAM,OAAO,iBAAiB;","names":[]}