@jmlweb/eslint-config-astro 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/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # @jmlweb/eslint-config-astro
2
+
3
+ ## 1.0.0
4
+
5
+ ### Added
6
+
7
+ - Initial release
8
+ - ESLint configuration for Astro projects
9
+ - Extends `@jmlweb/eslint-config-base` with Astro-specific rules
10
+ - Support for `.astro` files with proper TypeScript parsing
11
+ - Integration with `eslint-plugin-astro` recommended config
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # @jmlweb/eslint-config-astro
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@jmlweb/eslint-config-astro)](https://www.npmjs.com/package/@jmlweb/eslint-config-astro)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20.11.0-339933.svg)](https://nodejs.org/)
6
+ [![ESLint](https://img.shields.io/badge/ESLint-9.0%2B-4B32C3.svg)](https://eslint.org/)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-3178C6.svg)](https://www.typescriptlang.org/)
8
+ [![Astro](https://img.shields.io/badge/Astro-4.0%2B-FF5D01.svg)](https://astro.build/)
9
+
10
+ > ESLint configuration for Astro projects with TypeScript. Extends `@jmlweb/eslint-config-base` with Astro-specific rules and best practices for `.astro` files.
11
+
12
+ ## ✨ Features
13
+
14
+ - 🔒 **Strict Type Checking**: Inherits all strict TypeScript rules from base config
15
+ - 🚀 **Astro Support**: Enforces Astro-specific rules and patterns
16
+ - 📝 **Astro File Handling**: Proper linting for `.astro` files
17
+ - 📦 **Import Management**: Enforces type-only imports with inline style + automatic sorting
18
+ - 🎯 **Code Quality**: Prevents common Astro pitfalls and anti-patterns
19
+ - 🎨 **Prettier Integration**: Disables all ESLint rules that conflict with Prettier
20
+ - 🚀 **Flat Config**: Uses ESLint 9+ flat config format (latest stable)
21
+
22
+ ## 📦 Installation
23
+
24
+ ```bash
25
+ npm install --save-dev @jmlweb/eslint-config-astro eslint @eslint/js typescript-eslint eslint-config-prettier eslint-plugin-astro eslint-plugin-simple-import-sort @jmlweb/eslint-config-base
26
+ ```
27
+
28
+ ## 🚀 Quick Start
29
+
30
+ Create an `eslint.config.js` file in your project root:
31
+
32
+ ```javascript
33
+ import astroConfig from '@jmlweb/eslint-config-astro';
34
+
35
+ export default [
36
+ ...astroConfig,
37
+ // Add your project-specific overrides here
38
+ ];
39
+ ```
40
+
41
+ ## 💡 Examples
42
+
43
+ ### Basic Setup
44
+
45
+ ```javascript
46
+ // eslint.config.js
47
+ import astroConfig from '@jmlweb/eslint-config-astro';
48
+
49
+ export default [...astroConfig];
50
+ ```
51
+
52
+ ### With Project-Specific Overrides
53
+
54
+ ```javascript
55
+ // eslint.config.js
56
+ import astroConfig from '@jmlweb/eslint-config-astro';
57
+
58
+ export default [
59
+ ...astroConfig,
60
+ {
61
+ files: ['**/*.test.ts', '**/*.test.astro'],
62
+ rules: {
63
+ // Allow any in tests
64
+ '@typescript-eslint/no-explicit-any': 'off',
65
+ // Allow console in tests
66
+ 'no-console': 'off',
67
+ },
68
+ },
69
+ {
70
+ ignores: ['dist/', '.astro/', 'node_modules/', '*.config.ts'],
71
+ },
72
+ ];
73
+ ```
74
+
75
+ ### With Custom Astro Settings
76
+
77
+ ```javascript
78
+ // eslint.config.js
79
+ import astroConfig from '@jmlweb/eslint-config-astro';
80
+
81
+ export default [
82
+ ...astroConfig,
83
+ {
84
+ files: ['**/*.astro'],
85
+ rules: {
86
+ // Customize Astro-specific rules
87
+ 'astro/no-conflict-set-directives': 'error',
88
+ 'astro/no-unused-define-vars-in-style': 'warn',
89
+ },
90
+ },
91
+ ];
92
+ ```
93
+
94
+ ## 📋 Configuration Details
95
+
96
+ ### Astro Files
97
+
98
+ This configuration applies Astro-specific rules to:
99
+
100
+ - `**/*.astro` - Astro component files
101
+
102
+ ### TypeScript Files
103
+
104
+ TypeScript rules are also applied to:
105
+
106
+ - `**/*.ts` - TypeScript files
107
+ - `**/*.tsx` - TypeScript React files (if used in Astro project)
108
+
109
+ ### Key Rules Enforced
110
+
111
+ | Rule | Level | Description |
112
+ | -------------------------------------- | ------- | ----------------------------------- |
113
+ | `astro/no-conflict-set-directives` | `error` | Prevents conflicting set directives |
114
+ | `astro/no-unused-define-vars-in-style` | `warn` | Warns about unused CSS variables |
115
+ | `simple-import-sort/imports` | `error` | Enforces import sorting |
116
+ | `simple-import-sort/exports` | `error` | Enforces export sorting |
117
+
118
+ ### What's Included
119
+
120
+ - ✅ All TypeScript ESLint rules from `@jmlweb/eslint-config-base`
121
+ - ✅ Astro recommended rules from `eslint-plugin-astro`
122
+ - ✅ Proper handling of `.astro` files with TypeScript parser
123
+ - ✅ Automatic import/export sorting
124
+ - ✅ Prettier conflict resolution
125
+
126
+ ## 🔄 Import Sorting
127
+
128
+ The configuration automatically sorts imports and enforces type-only imports:
129
+
130
+ **Before:**
131
+
132
+ ```typescript
133
+ import { Component } from './component';
134
+ import type { User } from './types';
135
+ import fs from 'fs';
136
+ ```
137
+
138
+ **After auto-fix:**
139
+
140
+ ```typescript
141
+ import fs from 'fs';
142
+ import type { User } from './types';
143
+ import { Component } from './component';
144
+ ```
145
+
146
+ Fix import order automatically:
147
+
148
+ ```bash
149
+ npx eslint --fix .
150
+ ```
151
+
152
+ ## 🎯 When to Use
153
+
154
+ Use this configuration when you want:
155
+
156
+ - ✅ Astro project development with TypeScript
157
+ - ✅ Maximum type safety with Astro
158
+ - ✅ Strict code quality standards for Astro code
159
+ - ✅ Consistent Astro patterns across the team
160
+ - ✅ Prevention of common Astro pitfalls
161
+
162
+ **For non-Astro TypeScript projects**, use [`@jmlweb/eslint-config-base`](../eslint-config-base) instead.
163
+
164
+ **For React projects**, use [`@jmlweb/eslint-config-react`](../eslint-config-react) instead.
165
+
166
+ ## 🔧 Extending the Configuration
167
+
168
+ You can extend or override the configuration for your specific needs:
169
+
170
+ ```javascript
171
+ import astroConfig from '@jmlweb/eslint-config-astro';
172
+
173
+ export default [
174
+ ...astroConfig,
175
+ {
176
+ files: ['**/*.test.ts', '**/*.test.astro'],
177
+ rules: {
178
+ // Test-specific rules
179
+ '@typescript-eslint/no-explicit-any': 'off',
180
+ },
181
+ },
182
+ {
183
+ ignores: ['dist/', '.astro/', 'node_modules/'],
184
+ },
185
+ ];
186
+ ```
187
+
188
+ ## 📝 Usage with Scripts
189
+
190
+ Add linting scripts to your `package.json`:
191
+
192
+ ```json
193
+ {
194
+ "scripts": {
195
+ "lint": "eslint .",
196
+ "lint:fix": "eslint . --fix"
197
+ }
198
+ }
199
+ ```
200
+
201
+ Then run:
202
+
203
+ ```bash
204
+ npm run lint # Lint all files
205
+ npm run lint:fix # Fix auto-fixable issues
206
+ ```
207
+
208
+ ## 📋 Requirements
209
+
210
+ - **Node.js** >= 20.11.0 (required for `import.meta.dirname` in config files)
211
+ - **ESLint** >= 9.0.0 (flat config format)
212
+ - **TypeScript** project with `tsconfig.json`
213
+ - **Astro** >= 4.0.0
214
+ - **TypeScript project service** enabled (automatic with this config)
215
+
216
+ ## 📦 Peer Dependencies
217
+
218
+ This package requires the following peer dependencies:
219
+
220
+ - `eslint` (^9.0.0)
221
+ - `@eslint/js` (^9.0.0)
222
+ - `typescript-eslint` (^8.0.0)
223
+ - `eslint-config-prettier` (^9.1.0)
224
+ - `eslint-plugin-astro` (^1.5.0)
225
+ - `eslint-plugin-simple-import-sort` (^12.0.0)
226
+ - `@jmlweb/eslint-config-base` (^2.0.2)
227
+
228
+ ## 🔗 Related Packages
229
+
230
+ - [`@jmlweb/eslint-config-base`](../eslint-config-base) - Base TypeScript ESLint config (extended by this package)
231
+ - [`@jmlweb/tsconfig-astro`](../tsconfig-astro) - TypeScript configuration for Astro projects
232
+ - [`@jmlweb/prettier-config-base`](../prettier-config-base) - Prettier config for consistent formatting
233
+
234
+ ## 📄 License
235
+
236
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ default: () => index_default
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var import_eslint_config_base = __toESM(require("@jmlweb/eslint-config-base"), 1);
37
+ var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
38
+ var import_eslint_plugin_astro = __toESM(require("eslint-plugin-astro"), 1);
39
+ var import_eslint_plugin_simple_import_sort = __toESM(require("eslint-plugin-simple-import-sort"), 1);
40
+ var config = [
41
+ ...import_eslint_config_base.default,
42
+ // Astro recommended config
43
+ ...import_eslint_plugin_astro.default.configs.recommended,
44
+ {
45
+ files: ["**/*.astro"],
46
+ plugins: {
47
+ astro: import_eslint_plugin_astro.default,
48
+ "simple-import-sort": import_eslint_plugin_simple_import_sort.default
49
+ },
50
+ languageOptions: {
51
+ parserOptions: {
52
+ parser: "@typescript-eslint/parser",
53
+ extraFileExtensions: [".astro"]
54
+ }
55
+ },
56
+ rules: {
57
+ ...import_eslint_config_prettier.default.rules,
58
+ "simple-import-sort/imports": "error",
59
+ "simple-import-sort/exports": "error"
60
+ }
61
+ },
62
+ // Also apply to TypeScript files in Astro projects
63
+ {
64
+ files: ["**/*.ts", "**/*.tsx"],
65
+ plugins: {
66
+ "simple-import-sort": import_eslint_plugin_simple_import_sort.default
67
+ },
68
+ rules: {
69
+ ...import_eslint_config_prettier.default.rules,
70
+ "simple-import-sort/imports": "error",
71
+ "simple-import-sort/exports": "error"
72
+ }
73
+ }
74
+ ];
75
+ var index_default = config;
@@ -0,0 +1,10 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ /**
4
+ * Astro ESLint configuration that extends the base TypeScript config.
5
+ * Includes Astro-specific rules and best practices for .astro files.
6
+ * For Astro project development with TypeScript.
7
+ */
8
+ declare const config: Linter.Config[];
9
+
10
+ export { config as default };
@@ -0,0 +1,10 @@
1
+ import { Linter } from 'eslint';
2
+
3
+ /**
4
+ * Astro ESLint configuration that extends the base TypeScript config.
5
+ * Includes Astro-specific rules and best practices for .astro files.
6
+ * For Astro project development with TypeScript.
7
+ */
8
+ declare const config: Linter.Config[];
9
+
10
+ export { config as default };
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
1
+ // src/index.ts
2
+ import baseConfig from "@jmlweb/eslint-config-base";
3
+ import prettierConfig from "eslint-config-prettier";
4
+ import astro from "eslint-plugin-astro";
5
+ import simpleImportSort from "eslint-plugin-simple-import-sort";
6
+ var config = [
7
+ ...baseConfig,
8
+ // Astro recommended config
9
+ ...astro.configs.recommended,
10
+ {
11
+ files: ["**/*.astro"],
12
+ plugins: {
13
+ astro,
14
+ "simple-import-sort": simpleImportSort
15
+ },
16
+ languageOptions: {
17
+ parserOptions: {
18
+ parser: "@typescript-eslint/parser",
19
+ extraFileExtensions: [".astro"]
20
+ }
21
+ },
22
+ rules: {
23
+ ...prettierConfig.rules,
24
+ "simple-import-sort/imports": "error",
25
+ "simple-import-sort/exports": "error"
26
+ }
27
+ },
28
+ // Also apply to TypeScript files in Astro projects
29
+ {
30
+ files: ["**/*.ts", "**/*.tsx"],
31
+ plugins: {
32
+ "simple-import-sort": simpleImportSort
33
+ },
34
+ rules: {
35
+ ...prettierConfig.rules,
36
+ "simple-import-sort/imports": "error",
37
+ "simple-import-sort/exports": "error"
38
+ }
39
+ }
40
+ ];
41
+ var index_default = config;
42
+ export {
43
+ index_default as default
44
+ };
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@jmlweb/eslint-config-astro",
3
+ "version": "1.0.0",
4
+ "description": "ESLint configuration for Astro projects with TypeScript. Extends @jmlweb/eslint-config-base with Astro-specific rules.",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "default": "./dist/index.cjs"
18
+ }
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md",
24
+ "CHANGELOG.md"
25
+ ],
26
+ "keywords": [
27
+ "code-quality",
28
+ "eslint",
29
+ "eslint-config",
30
+ "linting",
31
+ "astro",
32
+ "typescript"
33
+ ],
34
+ "author": "jmlweb",
35
+ "license": "MIT",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/jmlweb/tooling.git"
39
+ },
40
+ "bugs": "https://github.com/jmlweb/tooling/issues",
41
+ "homepage": "https://github.com/jmlweb/tooling/tree/main/packages/eslint-config-astro#readme",
42
+ "engines": {
43
+ "node": ">=20.11.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "peerDependencies": {
49
+ "@eslint/js": "^9.0.0",
50
+ "@jmlweb/eslint-config-base": "^2.0.2",
51
+ "eslint": "^9.0.0",
52
+ "eslint-config-prettier": "^9.1.0",
53
+ "eslint-plugin-astro": "^1.5.0",
54
+ "eslint-plugin-simple-import-sort": "^12.0.0",
55
+ "typescript-eslint": "^8.0.0"
56
+ },
57
+ "dependencies": {
58
+ "@jmlweb/eslint-config-base": "2.0.2"
59
+ },
60
+ "devDependencies": {
61
+ "@eslint/js": "^9.39.2",
62
+ "@types/eslint": "^9.6.1",
63
+ "eslint": "^9.39.2",
64
+ "eslint-config-prettier": "^10.1.8",
65
+ "eslint-plugin-astro": "^1.5.0",
66
+ "eslint-plugin-simple-import-sort": "^12.1.1",
67
+ "tsup": "^8.5.1",
68
+ "typescript": "^5.9.3",
69
+ "typescript-eslint": "^8.34.1",
70
+ "@jmlweb/eslint-config-base": "2.0.2",
71
+ "@jmlweb/tsconfig-internal": "0.0.1"
72
+ },
73
+ "scripts": {
74
+ "build": "tsup",
75
+ "clean": "rm -rf dist"
76
+ }
77
+ }