@tuomashatakka/eslint-config 2.4.0 โ 2.6.1
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 +120 -21
- package/eslint.config.mjs +0 -1
- package/index.mjs +16 -6
- package/package.json +14 -20
- package/rules.mjs +103 -476
- package/test/fixtures/basic-javascript.js +50 -0
- package/test/fixtures/complex-patterns.ts +120 -0
- package/test/fixtures/edge-cases.js +119 -0
- package/test/fixtures/jsx-formatting.jsx +137 -0
- package/test/fixtures/react-component.tsx +84 -0
- package/test/format-cases.mjs +197 -0
- package/test/test-runner.mjs +127 -0
package/README.md
CHANGED
|
@@ -1,20 +1,34 @@
|
|
|
1
1
|
# @tuomashatakka/eslint-config
|
|
2
2
|
|
|
3
|
-
> Opinionated yet functional
|
|
3
|
+
> Opinionated yet functional ESLint configuration with comprehensive TypeScript, React, and JSX support
|
|
4
4
|
|
|
5
|
-
For Next.js, React and TypeScript projects.
|
|
5
|
+
For Next.js, React and TypeScript projects using modern flat config format.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## ๐ Recent Updates (v2.5.0)
|
|
8
|
+
|
|
9
|
+
### โจ Major Improvements
|
|
10
|
+
- **Removed Tailwind ESLint Plugin** - Streamlined configuration by removing tailwindcss plugin dependency
|
|
11
|
+
- **Migrated React Rules to @stylistic/jsx** - Moved all React styling rules to the dedicated stylistic JSX plugin for better separation of concerns
|
|
12
|
+
- **Updated All Plugins to Latest Versions** - Comprehensive dependency modernization with compatibility fixes
|
|
13
|
+
- **Added Comprehensive Test Suite** - Complete test coverage for formatting scenarios and edge cases
|
|
14
|
+
|
|
15
|
+
### ๐ง Technical Modernization
|
|
16
|
+
- Updated `@stylistic/eslint-plugin` to v5.2.0
|
|
17
|
+
- Added `@stylistic/eslint-plugin-jsx` for dedicated JSX formatting
|
|
18
|
+
- Fixed deprecated `allowTemplateLiterals` configuration (migrated from boolean to 'always'/'never')
|
|
19
|
+
- Consolidated plugin architecture for better maintainability
|
|
20
|
+
|
|
21
|
+
## ๐ฆ Installation
|
|
8
22
|
|
|
9
23
|
```bash
|
|
10
24
|
npm install --save-dev @tuomashatakka/eslint-config
|
|
11
25
|
```
|
|
12
26
|
|
|
13
|
-
## Usage
|
|
27
|
+
## ๐ง Usage
|
|
14
28
|
|
|
15
29
|
### Using the full config
|
|
16
30
|
|
|
17
|
-
Create an `eslint.config.
|
|
31
|
+
Create an `eslint.config.mjs` file in your project root:
|
|
18
32
|
|
|
19
33
|
```javascript
|
|
20
34
|
import config from '@tuomashatakka/eslint-config'
|
|
@@ -38,28 +52,113 @@ export default [
|
|
|
38
52
|
]
|
|
39
53
|
```
|
|
40
54
|
|
|
41
|
-
|
|
55
|
+
### Custom Configuration
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
import { baseConfig, rules } from '@tuomashatakka/eslint-config'
|
|
59
|
+
|
|
60
|
+
export default [
|
|
61
|
+
...baseConfig,
|
|
62
|
+
{
|
|
63
|
+
// Your custom overrides
|
|
64
|
+
rules: {
|
|
65
|
+
...rules,
|
|
66
|
+
'no-console': 'off'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## ๐ฏ Features
|
|
73
|
+
|
|
74
|
+
### Code Quality Rules
|
|
75
|
+
- **Complexity Control** - Max complexity: 14, max statements: 40
|
|
76
|
+
- **Functional Patterns** - Encourages functional programming practices
|
|
77
|
+
- **Type Safety** - Comprehensive TypeScript integration
|
|
78
|
+
|
|
79
|
+
### Stylistic Formatting
|
|
80
|
+
- **Consistent Spacing** - Aligned object properties, consistent indentation
|
|
81
|
+
- **Modern Syntax** - Arrow functions, template literals, destructuring
|
|
82
|
+
- **JSX Excellence** - Dedicated JSX formatting with proper component patterns
|
|
83
|
+
|
|
84
|
+
### Plugin Integration
|
|
85
|
+
- **@stylistic/eslint-plugin** - Modern code formatting
|
|
86
|
+
- **@stylistic/eslint-plugin-jsx** - JSX-specific formatting rules
|
|
87
|
+
- **typescript-eslint** - TypeScript language support
|
|
88
|
+
- **eslint-plugin-react** - React component best practices
|
|
89
|
+
- **eslint-plugin-import** - Import/export management
|
|
90
|
+
- **Custom Plugins** - Specialized rules for code quality
|
|
91
|
+
|
|
92
|
+
## ๐งช Testing
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Run all tests
|
|
96
|
+
npm run test
|
|
97
|
+
|
|
98
|
+
# Test formatting capabilities
|
|
99
|
+
npm run test:format
|
|
100
|
+
|
|
101
|
+
# Lint the configuration itself
|
|
102
|
+
npm run lint
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Test Coverage
|
|
106
|
+
- โ
Basic JavaScript patterns
|
|
107
|
+
- โ
Complex TypeScript scenarios
|
|
108
|
+
- โ
React/JSX components
|
|
109
|
+
- โ
Edge cases and formatting challenges
|
|
110
|
+
|
|
111
|
+
## ๐ Structure
|
|
112
|
+
|
|
113
|
+
The package uses ESLint's flat config format and has a clean structure:
|
|
114
|
+
|
|
115
|
+
- `index.mjs` - Exports the full config, baseConfig, and rules
|
|
116
|
+
- `rules.mjs` - Contains all the ESLint rules organized by category
|
|
117
|
+
- `test/` - Comprehensive test suite with fixtures and runners
|
|
118
|
+
|
|
119
|
+
## ๐ Migration Guide
|
|
120
|
+
|
|
121
|
+
### From v2.4.0 to v2.5.0
|
|
122
|
+
|
|
123
|
+
1. **Remove tailwindcss dependency** (if manually installed)
|
|
124
|
+
2. **Update package.json** - Latest versions are automatically handled
|
|
125
|
+
3. **No breaking changes** - All existing code continues to work
|
|
126
|
+
4. **Enhanced JSX support** - Better formatting for React components
|
|
127
|
+
|
|
128
|
+
### Deprecated Configurations
|
|
129
|
+
- `allowTemplateLiterals: true` โ `allowTemplateLiterals: 'always'`
|
|
130
|
+
- Tailwind CSS rules removed (use dedicated Tailwind tools instead)
|
|
131
|
+
|
|
132
|
+
## ๐ Troubleshooting
|
|
133
|
+
|
|
134
|
+
### Common Issues
|
|
135
|
+
|
|
136
|
+
**Template literal warnings:**
|
|
137
|
+
- Update to v2.5.0+ for the fixed configuration
|
|
42
138
|
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
- Stylistic rules for consistent code formatting
|
|
47
|
-
- Import/export validation
|
|
139
|
+
**JSX formatting issues:**
|
|
140
|
+
- Ensure you're using files with proper extensions (.jsx, .tsx)
|
|
141
|
+
- Check that React is properly detected in settings
|
|
48
142
|
|
|
49
|
-
|
|
143
|
+
**TypeScript parsing errors:**
|
|
144
|
+
- Verify your tsconfig.json is valid
|
|
145
|
+
- Ensure proper file extensions (.ts, .tsx)
|
|
50
146
|
|
|
51
|
-
|
|
147
|
+
## ๐ Performance
|
|
52
148
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
149
|
+
- **Zero runtime dependencies** in production
|
|
150
|
+
- **Fast linting** with optimized rule selection
|
|
151
|
+
- **Minimal plugin surface area** for better performance
|
|
152
|
+
- **Comprehensive but efficient** rule set
|
|
55
153
|
|
|
56
|
-
|
|
154
|
+
## ๐ค Contributing
|
|
57
155
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
156
|
+
1. Fork the repository
|
|
157
|
+
2. Create a feature branch
|
|
158
|
+
3. Add tests for new rules
|
|
159
|
+
4. Run the test suite: `npm run test`
|
|
160
|
+
5. Submit a pull request
|
|
62
161
|
|
|
63
162
|
## License
|
|
64
163
|
|
|
65
|
-
ISC
|
|
164
|
+
ISC
|
package/eslint.config.mjs
CHANGED
package/index.mjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import stylistic from '@stylistic/eslint-plugin'
|
|
2
|
+
import stylisticJsx from '@stylistic/eslint-plugin-jsx'
|
|
2
3
|
import tsplugin from '@typescript-eslint/eslint-plugin'
|
|
3
4
|
import importPlugin from 'eslint-plugin-import'
|
|
4
5
|
import noInlineMultilineTypesPlugin from 'eslint-plugin-no-inline-multiline-types'
|
|
5
6
|
import whitespacedPlugin from 'eslint-plugin-whitespaced'
|
|
6
7
|
import omitPlugin from 'eslint-plugin-omit-unnecessary'
|
|
7
8
|
import react from 'eslint-plugin-react'
|
|
8
|
-
import
|
|
9
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
9
10
|
import globals from 'globals'
|
|
10
11
|
import tseslint from 'typescript-eslint'
|
|
11
|
-
|
|
12
12
|
import { rules } from './rules.mjs'
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
const plugins = {
|
|
16
16
|
'react': react,
|
|
17
|
+
'react-hooks': reactHooks,
|
|
17
18
|
'import': importPlugin,
|
|
18
19
|
'@stylistic': stylistic,
|
|
19
20
|
'@typescript-eslint': tsplugin,
|
|
20
|
-
'tailwindcss': tailwindCssPlugin,
|
|
21
21
|
'omit': omitPlugin,
|
|
22
22
|
'no-inline-types': noInlineMultilineTypesPlugin,
|
|
23
23
|
'whitespaced': whitespacedPlugin,
|
|
@@ -38,21 +38,31 @@ export const baseConfig = {
|
|
|
38
38
|
'import/internal-regex': '^@/(.+)',
|
|
39
39
|
},
|
|
40
40
|
ignores: [ '**/node_modules/**' ],
|
|
41
|
-
plugins
|
|
41
|
+
plugins: {
|
|
42
|
+
...plugins,
|
|
43
|
+
// Merge stylistic JSX plugin into the main stylistic namespace
|
|
44
|
+
'@stylistic': {
|
|
45
|
+
...stylistic,
|
|
46
|
+
rules: {
|
|
47
|
+
...stylistic.rules,
|
|
48
|
+
...stylisticJsx.rules,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
42
52
|
rules,
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
|
|
46
55
|
/**
|
|
47
56
|
* @type {tseslint.configs.base}
|
|
48
57
|
*/
|
|
58
|
+
|
|
49
59
|
export const config = tseslint.config(
|
|
50
60
|
...tseslint.configs.recommended,
|
|
51
61
|
baseConfig)
|
|
52
62
|
|
|
53
|
-
|
|
54
63
|
/**
|
|
55
64
|
* @summary ESLint configuration
|
|
56
65
|
* @description Opinionated yet functional AF base config for ESLint
|
|
57
66
|
*/
|
|
67
|
+
|
|
58
68
|
export default config
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuomashatakka/eslint-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Default eslint configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint": "eslint . --config index.mjs"
|
|
8
|
+
"lint": "eslint . --config index.mjs",
|
|
9
|
+
"test": "node test/test-runner.mjs",
|
|
10
|
+
"test:format": "node test/format-cases.mjs"
|
|
9
11
|
},
|
|
10
12
|
"repository": {
|
|
11
13
|
"type": "git",
|
|
@@ -25,16 +27,15 @@
|
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"eslint": "^9.31.0",
|
|
28
|
-
"@stylistic/eslint-plugin": "^2.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"@stylistic/eslint-plugin": "^5.2.0",
|
|
31
|
+
"@stylistic/eslint-plugin-jsx": "^2.13.0",
|
|
32
|
+
"typescript-eslint": "^8.37.0",
|
|
33
|
+
"globals": "^16.3.0",
|
|
34
|
+
"typescript": "^5.8.3",
|
|
35
|
+
"eslint-plugin-react": "^7.37.5",
|
|
33
36
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
34
|
-
"eslint-plugin-import": "
|
|
35
|
-
"eslint-plugin
|
|
36
|
-
"eslint-plugin-next": "^0.0.0",
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "*",
|
|
37
|
+
"eslint-plugin-import": "^2.32.0",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
38
39
|
"eslint-plugin-no-inline-multiline-types": "^0.0.5",
|
|
39
40
|
"eslint-plugin-omit-unnecessary": "^0.0.3",
|
|
40
41
|
"eslint-plugin-whitespaced": "^1.0.2"
|
|
@@ -43,17 +44,10 @@
|
|
|
43
44
|
"@eslint/compat": "^1.3.1",
|
|
44
45
|
"@eslint/eslintrc": "^3.3.1",
|
|
45
46
|
"@eslint/js": "^9.31.0",
|
|
46
|
-
"@stylistic/eslint-plugin": "^
|
|
47
|
-
"@stylistic/eslint-plugin-ts": "^2.13.0",
|
|
47
|
+
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
48
48
|
"@types/eslint__eslintrc": "^2.1.2",
|
|
49
49
|
"@types/eslint__js": "^8.42.3",
|
|
50
|
-
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
51
50
|
"@typescript-eslint/parser": "^8.37.0",
|
|
52
|
-
"eslint-plugin-block-padding": "^0.0.3"
|
|
53
|
-
"eslint-plugin-import": "^2.32.0",
|
|
54
|
-
"eslint-plugin-react": "^7.37.5",
|
|
55
|
-
"globals": "^15.15.0",
|
|
56
|
-
"typescript": "^5.8.3",
|
|
57
|
-
"typescript-eslint": "^8.37.0"
|
|
51
|
+
"eslint-plugin-block-padding": "^0.0.3"
|
|
58
52
|
}
|
|
59
53
|
}
|