@tuomashatakka/eslint-config 2.2.1 → 2.2.3
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 +55 -3
- package/eslint.config.js +4 -0
- package/{eslint.config.mjs → index.js} +25 -6
- package/package.json +3 -3
- package/{rules.mjs → rules.js} +12 -3
- package/index.mjs +0 -17
package/README.md
CHANGED
|
@@ -1,9 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tuomashatakka/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Opinionated yet functional AF base config for ESLint using the new flat config format
|
|
4
4
|
|
|
5
|
-
For Next, React and
|
|
5
|
+
For Next.js, React and TypeScript projects.
|
|
6
6
|
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --save-dev @tuomashatakka/eslint-config
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Using the full config
|
|
16
|
+
|
|
17
|
+
Create an `eslint.config.js` file in your project root:
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
import config from '@tuomashatakka/eslint-config'
|
|
21
|
+
|
|
22
|
+
export default config
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Using just the rules
|
|
26
|
+
|
|
27
|
+
If you want to use only the rules in your own config:
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
import { rules } from '@tuomashatakka/eslint-config'
|
|
31
|
+
|
|
32
|
+
export default [
|
|
33
|
+
// Your custom config here
|
|
34
|
+
{
|
|
35
|
+
// ...
|
|
36
|
+
rules
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
- TypeScript support
|
|
44
|
+
- React/JSX support
|
|
45
|
+
- Modern JavaScript features
|
|
46
|
+
- Stylistic rules for consistent code formatting
|
|
47
|
+
- Import/export validation
|
|
48
|
+
|
|
49
|
+
## Structure
|
|
50
|
+
|
|
51
|
+
The package uses ESLint's flat config format and has a simple structure:
|
|
52
|
+
|
|
53
|
+
- `index.mjs` - Exports the full config and rules
|
|
54
|
+
- `rules.mjs` - Contains all the ESLint rules
|
|
7
55
|
|
|
8
56
|
### Todo
|
|
9
57
|
|
|
@@ -11,3 +59,7 @@ For Next, React and TS
|
|
|
11
59
|
- I really love Python's enforced linting style for having two rows between major blocks
|
|
12
60
|
and 1 row between minor. I should finish my block padding plugin some day for the ESLinter.
|
|
13
61
|
My linting rules would really appreciate that.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
ISC
|
package/eslint.config.js
ADDED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable multiline-comment-style */
|
|
2
1
|
import stylistic from '@stylistic/eslint-plugin'
|
|
3
2
|
import tsplugin from '@typescript-eslint/eslint-plugin'
|
|
4
3
|
import importPlugin from 'eslint-plugin-import'
|
|
@@ -6,7 +5,7 @@ import react from 'eslint-plugin-react'
|
|
|
6
5
|
import globals from 'globals'
|
|
7
6
|
import tseslint from 'typescript-eslint'
|
|
8
7
|
|
|
9
|
-
import rules from './rules.
|
|
8
|
+
import { rules } from './rules.js'
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
const plugins = {
|
|
@@ -18,11 +17,13 @@ const plugins = {
|
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* @type {tseslint.configs.base}
|
|
21
|
-
|
|
20
|
+
*/
|
|
22
21
|
const config = tseslint.config(
|
|
23
22
|
...tseslint.configs.recommended,
|
|
24
23
|
{
|
|
25
24
|
languageOptions: {
|
|
25
|
+
ecmaVersion: 'latest',
|
|
26
|
+
sourceType: 'module',
|
|
26
27
|
parserOptions: {
|
|
27
28
|
ecmaFeatures: {
|
|
28
29
|
jsx: true,
|
|
@@ -46,13 +47,31 @@ const config = tseslint.config(
|
|
|
46
47
|
},
|
|
47
48
|
plugins,
|
|
48
49
|
rules,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
files: [ '**/*.{js,jsx,mjs,cjs,ts,tsx}' ],
|
|
53
|
+
languageOptions: {
|
|
54
|
+
ecmaVersion: 'latest',
|
|
55
|
+
sourceType: 'module',
|
|
56
|
+
parserOptions: {
|
|
57
|
+
ecmaFeatures: {
|
|
58
|
+
jsx: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
globals: {
|
|
62
|
+
...globals.browser,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
49
65
|
}
|
|
50
66
|
)
|
|
51
67
|
|
|
52
68
|
/**
|
|
53
69
|
* @summary ESLint configuration
|
|
54
70
|
* @description Opinionated yet functional AF base config for ESLint
|
|
55
|
-
|
|
56
|
-
* @version {@version}
|
|
57
|
-
**/
|
|
71
|
+
*/
|
|
58
72
|
export default config
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
config,
|
|
76
|
+
rules
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuomashatakka/eslint-config",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.3",
|
|
4
4
|
"description": "Default eslint configuration",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "index.
|
|
6
|
+
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint": "eslint . --config
|
|
8
|
+
"lint": "eslint . --config index.mjs"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
package/{rules.mjs → rules.js}
RENAMED
|
@@ -37,9 +37,7 @@ export const rules = {
|
|
|
37
37
|
],
|
|
38
38
|
|
|
39
39
|
// Typescript
|
|
40
|
-
'@
|
|
41
|
-
'@typescript-eslint/no-unused-vars': [ 'warn' ],
|
|
42
|
-
'@typescript-eslint/no-explicit-any': [ 'warn' ],
|
|
40
|
+
'@stylistic/ban-ts-comment': [ 'off', 'allow-single-line' ],
|
|
43
41
|
|
|
44
42
|
// Enforced practices (enforce functional and orthogonal code)
|
|
45
43
|
'complexity': [ 'warn', { max: 11 }],
|
|
@@ -182,6 +180,17 @@ export const rules = {
|
|
|
182
180
|
{ blankLine: 'any',
|
|
183
181
|
prev: [ 'multiline-expression', 'function', 'block-like', 'block' ],
|
|
184
182
|
next: [ 'multiline-expression', 'function', 'block-like', 'block' ]}],
|
|
183
|
+
|
|
184
|
+
'@stylistic/jsx-closing-bracket-location': [ 0 ],
|
|
185
|
+
'@stylistic/jsx-one-expression-per-line': [ 'warn', { allow: 'non-jsx' }],
|
|
186
|
+
'react/jsx-one-expression-per-line': [ 'warn', { allow: 'non-jsx' }],
|
|
187
|
+
'react/jsx-closing-bracket-location': [ 0 ],
|
|
188
|
+
'react/jsx-curly-spacing': [ 0 ],
|
|
189
|
+
'@stylistic/jsx-curly-spacing': [ 'warn', { spacing: { objectLiterals: 'always' }}],
|
|
190
|
+
'@stylistic/implicit-arrow-linebreak': [ 0 ],
|
|
191
|
+
'@stylistic/arrow-parens': [ 1, 'as-needed', { requireForBlockBody: true }],
|
|
192
|
+
'@stylistic/space-before-function-paren': [ 1, 'always' ]
|
|
185
193
|
}
|
|
186
194
|
|
|
195
|
+
// Make sure we export both named and default exports
|
|
187
196
|
export default rules
|
package/index.mjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import tseslint from 'typescript-eslint'
|
|
2
|
-
|
|
3
|
-
import config from './eslint.config.mjs'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const configType = tseslint.configs.base
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @name config
|
|
10
|
-
* @type {typeof configType}
|
|
11
|
-
*/
|
|
12
|
-
export default config
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
config,
|
|
16
|
-
configType
|
|
17
|
-
}
|