@jmlweb/eslint-config-base-js 1.0.3 → 1.0.4
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 +6 -0
- package/README.md +42 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
## 📦 Installation
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
|
|
22
|
+
pnpm add -D @jmlweb/eslint-config-base-js eslint @eslint/js eslint-config-prettier eslint-plugin-simple-import-sort
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
@@ -159,7 +159,7 @@ import { Component } from './component';
|
|
|
159
159
|
Fix import order automatically:
|
|
160
160
|
|
|
161
161
|
```bash
|
|
162
|
-
|
|
162
|
+
pnpm exec eslint --fix .
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
## 🎨 Prettier Integration
|
|
@@ -168,6 +168,44 @@ This configuration disables all ESLint rules that conflict with Prettier, allowi
|
|
|
168
168
|
|
|
169
169
|
**Recommended**: Use [`@jmlweb/prettier-config-base`](../prettier-config-base) for consistent formatting.
|
|
170
170
|
|
|
171
|
+
## 🤔 Why Use This?
|
|
172
|
+
|
|
173
|
+
> **Philosophy**: Code quality and consistency through simple, battle-tested rules. Foundation for specialized configs.
|
|
174
|
+
|
|
175
|
+
This package provides the JavaScript linting foundation used across all other configs in the `@jmlweb` ecosystem. It focuses on code quality and best practices while delegating formatting to Prettier.
|
|
176
|
+
|
|
177
|
+
### Design Decisions
|
|
178
|
+
|
|
179
|
+
**ESLint Recommended Rules Only**: Uses `@eslint/js` recommended config without additional opinionated rules
|
|
180
|
+
|
|
181
|
+
- **Why**: Provides a solid baseline of best practices without being overly strict. Allows specialized configs to add their own rules based on context (TypeScript, React, etc.)
|
|
182
|
+
- **Trade-off**: Less opinionated than configs like Airbnb, but more flexible and maintainable as a foundation
|
|
183
|
+
- **When to override**: When you need stricter or more specific rules for your project (consider using specialized configs instead)
|
|
184
|
+
|
|
185
|
+
**Automatic Import Sorting**: Uses `eslint-plugin-simple-import-sort` for consistent import organization
|
|
186
|
+
|
|
187
|
+
- **Why**: Manual import organization is tedious and inconsistent. Automatic sorting ensures a predictable order that's easy to scan (built-ins → external → internal → relative)
|
|
188
|
+
- **Trade-off**: Initial formatting may reorder your manually organized imports, but consistency across the codebase is worth it
|
|
189
|
+
- **When to override**: Rarely needed - the default order works well for most projects
|
|
190
|
+
|
|
191
|
+
**Prettier Integration**: Includes `eslint-config-prettier` to disable conflicting rules
|
|
192
|
+
|
|
193
|
+
- **Why**: ESLint handles code quality, Prettier handles formatting. Trying to use both for formatting causes conflicts and frustration
|
|
194
|
+
- **Trade-off**: None - this is the recommended approach by both ESLint and Prettier teams
|
|
195
|
+
- **When to override**: Never - this prevents tooling conflicts
|
|
196
|
+
|
|
197
|
+
**Environment Agnostic**: No browser or Node.js globals by default
|
|
198
|
+
|
|
199
|
+
- **Why**: Projects should explicitly declare their runtime environment. This config is used as a foundation for both browser and Node.js projects
|
|
200
|
+
- **Trade-off**: Requires you to add globals in your config, but makes the base config more portable and explicit
|
|
201
|
+
- **When to override**: Always override by adding the globals your project needs (browser, Node.js, etc.)
|
|
202
|
+
|
|
203
|
+
**Flat Config Format**: Uses ESLint 9+ flat config (not legacy `.eslintrc`)
|
|
204
|
+
|
|
205
|
+
- **Why**: Flat config is the future of ESLint, offering better composition, clearer configuration, and improved performance
|
|
206
|
+
- **Trade-off**: Not compatible with older ESLint plugins that haven't migrated (rare)
|
|
207
|
+
- **When to override**: If you're on an older ESLint version (but you should upgrade)
|
|
208
|
+
|
|
171
209
|
## 🎯 When to Use
|
|
172
210
|
|
|
173
211
|
Use this package when you want:
|
|
@@ -217,8 +255,8 @@ Add linting scripts to your `package.json`:
|
|
|
217
255
|
Then run:
|
|
218
256
|
|
|
219
257
|
```bash
|
|
220
|
-
|
|
221
|
-
|
|
258
|
+
pnpm lint # Lint all files
|
|
259
|
+
pnpm lint:fix # Fix auto-fixable issues
|
|
222
260
|
```
|
|
223
261
|
|
|
224
262
|
## 📋 Requirements
|
package/package.json
CHANGED