eslint-config-gristow 2.0.20 → 3.0.0-alpha.2

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,75 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [3.0.0] - 2025-12-24
6
+
7
+ ### Breaking Changes
8
+
9
+ - **ESLint 9 Required**: This version requires ESLint 9.x and uses the new flat config format
10
+ - **Flat Config Only**: The legacy `.eslintrc.*` format is no longer supported
11
+ - **Node.js 18+**: Minimum Node.js version is now 18.0.0
12
+ - **ES Modules**: Package is now ESM-only (`"type": "module"`)
13
+ - **Svelte Removed**: Svelte configuration has been removed; use `sv create` or `npx sv add eslint` for Svelte projects
14
+
15
+ ### Added
16
+
17
+ - ESLint 9 flat config with `defineConfig()` support
18
+ - Custom Airbnb-style rule sets (replacing `eslint-config-airbnb-base` which hasn't updated for ESLint 9):
19
+ - `airbnb-best-practices.js` - ~65 best practice rules
20
+ - `airbnb-errors.js` - ~45 error prevention rules
21
+ - `airbnb-es6.js` - ~25 ES6+ rules
22
+ - `airbnb-style.js` - Style rules (formatting rules disabled for Prettier compatibility)
23
+ - `airbnb-variables.js` - ~12 variable-related rules
24
+ - `airbnb-imports.js` - ~45 import plugin rules
25
+ - `typescript-eslint` v8 integration (combines parser and plugin)
26
+ - `@eslint/js` for ESLint recommended rules
27
+ - `globals` package for environment global definitions
28
+ - Proper `exports` field in package.json
29
+ - Automated test suite with comprehensive rule detection tests
30
+ - `curly` rule re-enabled after Prettier config (enforces braces for all control statements)
31
+
32
+ ### Changed
33
+
34
+ - All rule files converted from CommonJS to ES Modules
35
+ - Configuration now uses `languageOptions` instead of `parser`/`parserOptions`/`env`
36
+ - TypeScript project service enabled by default (`projectService: true`)
37
+
38
+ ### Removed
39
+
40
+ - Legacy `.eslintrc.cjs` configuration
41
+ - Svelte support (use `sv create` instead)
42
+ - `eslint-config-airbnb-base` dependency
43
+ - `eslint-config-airbnb-typescript` dependency
44
+ - `@typescript-eslint/parser` (replaced by `typescript-eslint`)
45
+ - `@typescript-eslint/eslint-plugin` (replaced by `typescript-eslint`)
46
+
47
+ ### Migration Guide
48
+
49
+ 1. Update your ESLint config file from `.eslintrc.*` to `eslint.config.js`:
50
+
51
+ ```javascript
52
+ import { defineConfig } from 'eslint/config';
53
+ import gristowConfig from 'eslint-config-gristow';
54
+
55
+ export default defineConfig(
56
+ gristowConfig,
57
+ // Add your project-specific overrides here
58
+ );
59
+ ```
60
+
61
+ 2. Update your `package.json` scripts:
62
+ ```json
63
+ {
64
+ "scripts": {
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix"
67
+ }
68
+ }
69
+ ```
70
+
71
+ 3. For Svelte projects, use the ESLint setup from `sv create` or `npx sv add eslint` instead.
72
+
73
+ ## [2.x] - Previous Versions
74
+
75
+ See git history for changes in version 2.x and earlier.
@@ -0,0 +1,33 @@
1
+ // @ts-check
2
+ /**
3
+ * ESLint config for the eslint-config-gristow project itself.
4
+ * Extends the base config and adds allowDefaultProject for test files.
5
+ */
6
+ import { defineConfig } from 'eslint/config';
7
+ import baseConfig from './index.js';
8
+
9
+ export default defineConfig(
10
+ // Use our own base config
11
+ baseConfig,
12
+
13
+ // Override to allow test files that aren't in tsconfig
14
+ {
15
+ languageOptions: {
16
+ parserOptions: {
17
+ projectService: {
18
+ allowDefaultProject: [
19
+ '*.config.js',
20
+ '*.config.cjs',
21
+ '*.config.mjs',
22
+ '*.config.ts',
23
+ '.*.js',
24
+ '.*.cjs',
25
+ '.*.mjs',
26
+ 'test/sample.js',
27
+ 'test/fixtures/*.js',
28
+ ],
29
+ },
30
+ },
31
+ },
32
+ },
33
+ );
package/index.js CHANGED
@@ -1,3 +1,122 @@
1
- const eslintrc = require('./.eslintrc.cjs');
1
+ // @ts-check
2
+ /**
3
+ * eslint-config-gristow
4
+ *
5
+ * ESLint 9 flat config for JavaScript and TypeScript projects.
6
+ *
7
+ * Usage in your eslint.config.js:
8
+ *
9
+ * ```javascript
10
+ * import { defineConfig } from 'eslint/config';
11
+ * import gristowConfig from 'eslint-config-gristow';
12
+ *
13
+ * export default defineConfig(
14
+ * gristowConfig,
15
+ * // your additional config...
16
+ * );
17
+ * ```
18
+ */
19
+ import { defineConfig } from 'eslint/config';
20
+ import eslint from '@eslint/js';
21
+ import tseslint from 'typescript-eslint';
22
+ import eslintConfigPrettier from 'eslint-config-prettier';
23
+ import importPlugin from 'eslint-plugin-import';
24
+ import globals from 'globals';
2
25
 
3
- module.exports = eslintrc;
26
+ // Import our custom rule sets
27
+ import airbnbBaseRules from './rules/airbnb-base-rules.js';
28
+ import sharedRules from './rules/shared-rules.js';
29
+ import importRules from './rules/import-rules.js';
30
+ import typescriptOnlyRules from './rules/typescript-only-rules.js';
31
+
32
+ /**
33
+ * ESLint flat config for eslint-config-gristow
34
+ *
35
+ * This configuration provides:
36
+ * - ESLint recommended rules
37
+ * - TypeScript-ESLint recommended rules
38
+ * - Airbnb-style rules (custom implementation for ESLint 9)
39
+ * - Prettier compatibility
40
+ * - Import plugin rules
41
+ */
42
+ export default defineConfig(
43
+ // Global ignores
44
+ {
45
+ ignores: [
46
+ '**/node_modules/**',
47
+ '**/dist/**',
48
+ '**/build/**',
49
+ '**/.svelte-kit/**',
50
+ ],
51
+ },
52
+
53
+ // Base ESLint recommended
54
+ eslint.configs.recommended,
55
+
56
+ // TypeScript recommended
57
+ tseslint.configs.recommended,
58
+
59
+ // Main configuration
60
+ {
61
+ plugins: {
62
+ '@typescript-eslint': tseslint.plugin,
63
+ 'import': importPlugin,
64
+ },
65
+ languageOptions: {
66
+ parser: tseslint.parser,
67
+ parserOptions: {
68
+ sourceType: 'module',
69
+ ecmaVersion: 2020,
70
+ projectService: {
71
+ // Allow common config files to be linted without being in tsconfig
72
+ allowDefaultProject: [
73
+ '*.config.js',
74
+ '*.config.cjs',
75
+ '*.config.mjs',
76
+ '*.config.ts',
77
+ '.*.js',
78
+ '.*.cjs',
79
+ '.*.mjs',
80
+ ],
81
+ },
82
+ },
83
+ globals: {
84
+ ...globals.browser,
85
+ ...globals.es2017,
86
+ ...globals.node,
87
+ },
88
+ },
89
+ settings: {
90
+ 'import/parsers': {
91
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
92
+ },
93
+ 'import/resolver': {
94
+ typescript: true,
95
+ },
96
+ },
97
+ rules: {
98
+ // Apply Airbnb base rules first
99
+ ...airbnbBaseRules,
100
+ // Then our shared rules (which override some Airbnb rules)
101
+ ...sharedRules,
102
+ // Then import-specific rules
103
+ ...importRules,
104
+ },
105
+ },
106
+
107
+ // TypeScript-specific overrides
108
+ {
109
+ files: ['**/*.ts', '**/*.tsx'],
110
+ rules: typescriptOnlyRules,
111
+ },
112
+
113
+ // Prettier must be last to override formatting rules
114
+ eslintConfigPrettier,
115
+
116
+ // Re-enable curly after Prettier (we want this enforced for code safety)
117
+ {
118
+ rules: {
119
+ curly: ['error', 'all'],
120
+ },
121
+ },
122
+ );
package/package.json CHANGED
@@ -1,58 +1,56 @@
1
1
  {
2
2
  "name": "eslint-config-gristow",
3
- "version": "2.0.20",
4
- "description": "Eslint settings for Greg Ristow",
3
+ "version": "3.0.0-alpha.2",
4
+ "description": "ESLint 9 flat config for JavaScript and TypeScript projects",
5
+ "type": "module",
5
6
  "main": "index.js",
7
+ "exports": {
8
+ ".": "./index.js",
9
+ "./eslint.config.js": "./eslint.config.js"
10
+ },
6
11
  "scripts": {
7
- "lint": "eslint .",
8
- "lint:fix": "eslint . --fix"
12
+ "lint": "eslint . --ignore-pattern test/fixtures/",
13
+ "lint:fix": "eslint . --fix --ignore-pattern test/fixtures/",
14
+ "test": "node --test test/rules.test.js",
15
+ "test:validate": "node test/validate-config.js"
9
16
  },
10
- "author": "",
17
+ "author": "Greg Ristow",
11
18
  "license": "ISC",
19
+ "keywords": [
20
+ "eslint",
21
+ "eslintconfig",
22
+ "eslint-config",
23
+ "typescript",
24
+ "flat-config"
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/gristow/eslint-config-gristow"
29
+ },
30
+ "engines": {
31
+ "node": ">=18.0.0"
32
+ },
33
+ "files": [
34
+ "index.js",
35
+ "eslint.config.js",
36
+ "rules/",
37
+ "README.md",
38
+ "CHANGELOG.md"
39
+ ],
12
40
  "dependencies": {
13
- "@typescript-eslint/eslint-plugin": "^5.59.5",
14
- "@typescript-eslint/parser": "^5.59.5",
15
- "eslint": "^8.41.0",
16
- "eslint-config-airbnb": "^19.0.4",
17
- "eslint-config-airbnb-base": "^15.0.0",
18
- "eslint-config-airbnb-typescript": "^17.0.0",
19
- "eslint-config-prettier": "^8.5.0",
20
- "eslint-import-resolver-typescript": "^3.5.5",
21
- "eslint-plugin-html": "^7.1.0",
22
- "eslint-plugin-import": "^2.27.5",
23
- "eslint-plugin-jsdoc": "^44.2.3",
24
- "eslint-plugin-jsx-a11y": "^6.4.1",
25
- "eslint-plugin-prettier": "^4.2.1",
26
- "eslint-plugin-react": "^7.24.0",
27
- "eslint-plugin-react-hooks": "^4.2.0",
28
- "eslint-plugin-svelte": "^2.29.0",
29
- "eslint-plugin-tsdoc": "^0.2.14",
30
- "prettier": "^2.8.8"
41
+ "@eslint/js": "^9.0.0",
42
+ "eslint-config-prettier": "^10.0.0",
43
+ "eslint-import-resolver-typescript": "^3.6.0",
44
+ "eslint-plugin-import": "^2.31.0",
45
+ "globals": "^16.0.0",
46
+ "typescript-eslint": "^8.0.0"
31
47
  },
32
48
  "peerDependencies": {
33
- "@typescript-eslint/eslint-plugin": "^5.59.5",
34
- "@typescript-eslint/parser": "^5.59.5",
35
- "eslint": ">=8.40.0",
36
- "eslint-config-airbnb": "^18.2.1",
37
- "eslint-config-airbnb-base": "^15.0.0",
38
- "eslint-config-airbnb-typescript": "^17.0.0",
39
- "eslint-config-prettier": "^8.3.0",
40
- "eslint-import-resolver-typescript": "^3.5.5",
41
- "eslint-plugin-html": "^7.1.0",
42
- "eslint-plugin-import": "^2.27.5",
43
- "eslint-plugin-jsdoc": "^44.2.3",
44
- "eslint-plugin-jsx-a11y": "^6.4.1",
45
- "eslint-plugin-prettier": "^4.2.1",
46
- "eslint-plugin-react": "^7.24.0",
47
- "eslint-plugin-react-hooks": "^4.2.0",
48
- "eslint-plugin-svelte": "^2.28.0",
49
- "eslint-plugin-tsdoc": "^0.2.14",
50
- "prettier": "^2.8.6",
51
- "typescript": "^5.0.4"
49
+ "eslint": "^9.0.0",
50
+ "typescript": "^5.0.0"
52
51
  },
53
52
  "devDependencies": {
54
- "eslint-config-airbnb-base": "^15.0.0",
55
- "eslint-plugin-tsdoc": "^0.2.14",
56
- "typescript": ">=5.0.4"
53
+ "eslint": "^9.0.0",
54
+ "typescript": "^5.0.0"
57
55
  }
58
56
  }
package/readme.md CHANGED
@@ -1,91 +1,101 @@
1
1
  # eslint-config-gristow
2
2
 
3
- A somewhat opinonated eslint configuration for js, ts and svelte.
3
+ An opinionated ESLint configuration for JavaScript and TypeScript projects.
4
4
 
5
- npm install --dev eslint-config-gristow
5
+ **Version 3.x** - ESLint 9 flat config. For ESLint 8, use version 2.x.
6
6
 
7
- ## Local / Per Project Install
7
+ ## Installation
8
8
 
9
- 1. `yarn add -D eslint-config-gristow`;
10
- 2. Then we need to install everything needed by the config:
11
-
12
- ```
13
- npx install-peerdeps --dev eslint-config-gristow
9
+ ```bash
10
+ npm install --save-dev eslint-config-gristow eslint
14
11
  ```
15
12
 
16
- 3. You can see in your package.json there are now a big list of devDependencies.
13
+ ## Usage
17
14
 
18
- 4. Create a `.eslintrc` file in the root of your project's directory (it should live where package.json does). Your `.eslintrc.js` file should look like this:
15
+ Create an `eslint.config.js` (or `eslint.config.mjs`) in your project root:
19
16
 
20
- ```js
21
- module.exports = {
22
- extends: ['gristow'],
23
- // This is critical for allowing the import parser to be aware
24
- // of any paths configured in .tsconfig.json
25
- settings: {
26
- 'import/resolver/typescript': {
27
- project: './tsconfig.json',
28
- },
29
- },
30
- };
17
+ ```javascript
18
+ import { defineConfig } from 'eslint/config';
19
+ import gristowConfig from 'eslint-config-gristow';
20
+
21
+ export default defineConfig(
22
+ gristowConfig,
23
+ // Add your project-specific overrides here
24
+ );
31
25
  ```
32
26
 
33
- 5. If your project uses, svelte, instead extend gristow/svelte:
34
- ```js
35
- module.exports = {
36
- extends: ['gristow/svelte'],
37
- // This is critical for allowing the import parser to be aware
38
- // of any paths configured in .tsconfig.json
27
+ ### With TypeScript Path Aliases
28
+
29
+ If your project uses TypeScript path aliases, configure the import resolver:
30
+
31
+ ```javascript
32
+ import { defineConfig } from 'eslint/config';
33
+ import gristowConfig from 'eslint-config-gristow';
34
+
35
+ export default defineConfig(
36
+ gristowConfig,
37
+ {
39
38
  settings: {
40
- 'import/resolver/typescript': {
41
- project: './tsconfig.json',
39
+ 'import/resolver': {
40
+ typescript: {
41
+ project: './tsconfig.json',
42
+ },
42
43
  },
43
44
  },
44
- };
45
+ },
46
+ );
45
47
  ```
46
48
 
47
- 6. You can add two scripts to your package.json to lint and/or fix:
49
+ ## Scripts
50
+
51
+ Add these scripts to your `package.json`:
48
52
 
49
53
  ```json
50
- "scripts": {
51
- "lint": "eslint .",
52
- "lint:fix": "eslint . --fix"
53
- },
54
+ {
55
+ "scripts": {
56
+ "lint": "eslint .",
57
+ "lint:fix": "eslint . --fix"
58
+ }
59
+ }
54
60
  ```
55
61
 
56
- 7. Now you can manually lint your code by running `npm run lint` and fix all fixable issues with `npm run lint:fix`. You probably want your editor to do this though.
57
-
58
- ## With VS Code
59
-
60
- Once you have the above installed, you probably want your editor to lint and fix for you. Here are the instructions for VS Code:
62
+ ## VS Code Setup
61
63
 
62
- 1. Install the [ESLint package](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
64
+ 1. Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
63
65
 
64
- 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:
66
+ 2. Add to your VS Code settings (`.vscode/settings.json`):
65
67
 
66
68
  ```json
67
- {
69
+ {
68
70
  "[javascript]": {
69
71
  "editor.codeActionsOnSave": {
70
- "source.fixAll.eslint": true
72
+ "source.fixAll.eslint": "explicit"
71
73
  }
72
- },
74
+ },
73
75
  "[typescript]": {
74
76
  "editor.codeActionsOnSave": {
75
- "source.fixAll.eslint": true
77
+ "source.fixAll.eslint": "explicit"
76
78
  }
77
- },
78
- "[svelte]": {
79
- "editor.defaultFormatter": "svelte.svelte-vscode",
80
- "editor.formatOnSave": true,
81
- "editor.codeActionsOnSave": {
82
- "source.fixAll.eslint": true
83
- }
84
79
  },
85
- // This line is CRITICAL for enabling eslint checking of svelte files,
86
- // otherwise they are ignored by default (despite the above!)
87
- "eslint.validate": ["javascript", "typescript", "svelte"],
80
+ "eslint.validate": ["javascript", "typescript"],
88
81
  "editor.defaultFormatter": "esbenp.prettier-vscode",
89
82
  "editor.formatOnSave": true
90
83
  }
91
84
  ```
85
+
86
+ ## What's Included
87
+
88
+ This config extends:
89
+ - ESLint recommended rules
90
+ - TypeScript-ESLint recommended rules
91
+ - Airbnb-style rules (custom ESLint 9 implementation)
92
+ - Prettier compatibility
93
+
94
+ ## Svelte Projects
95
+
96
+ For Svelte/SvelteKit projects, use the ESLint configuration provided by `sv create`
97
+ or `npx sv add eslint`, which provides better integration with Svelte 5 and SvelteKit.
98
+
99
+ ## License
100
+
101
+ ISC
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Airbnb Base Rules Aggregator
3
+ * Combines all Airbnb ESLint rules for ESLint 9 compatibility
4
+ *
5
+ * This replaces the eslint-config-airbnb-base package which has not been
6
+ * updated for ESLint 9's flat config format.
7
+ *
8
+ * @see https://github.com/airbnb/javascript
9
+ */
10
+ import bestPractices from './airbnb-best-practices.js';
11
+ import errors from './airbnb-errors.js';
12
+ import es6 from './airbnb-es6.js';
13
+ import style from './airbnb-style.js';
14
+ import variables from './airbnb-variables.js';
15
+ import imports from './airbnb-imports.js';
16
+
17
+ export default {
18
+ ...bestPractices,
19
+ ...errors,
20
+ ...es6,
21
+ ...style,
22
+ ...variables,
23
+ ...imports,
24
+ };
25
+
26
+ // Also export individual rule sets for selective use
27
+ export {
28
+ bestPractices,
29
+ errors,
30
+ es6,
31
+ style,
32
+ variables,
33
+ imports,
34
+ };