@tuomashatakka/eslint-config 2.1.4 → 2.2.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "editor.tabSize": 2
3
+ }
package/eslint.config.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  /* eslint-disable multiline-comment-style */
2
- import eslint from '@eslint/js'
3
2
  import stylistic from '@stylistic/eslint-plugin'
4
3
  import tsplugin from '@typescript-eslint/eslint-plugin'
5
4
  import importPlugin from 'eslint-plugin-import'
@@ -9,41 +8,45 @@ import tseslint from 'typescript-eslint'
9
8
  import rules from './rules.mjs'
10
9
 
11
10
 
12
- const ignores = [
13
- '**/*.js',
14
- ]
11
+ const plugins = {
12
+ 'react': react,
13
+ 'import': importPlugin,
14
+ '@stylistic': stylistic,
15
+ '@typescript-eslint': tsplugin,
16
+ }
15
17
 
16
18
  /**
17
- * @type {import('typescript-eslint').Config}
18
- * */
19
+ * @type {tseslint.configs.base}
20
+ **/
19
21
  const config = tseslint.config(
22
+ ...tseslint.configs.recommended,
20
23
  {
21
- ...eslint.configs.recommended,
22
- ignores,
23
- },
24
- {
25
- plugins: {
26
- '@stylistic': stylistic,
27
- 'react': react,
28
- 'import': importPlugin,
29
- '@typescript-eslint': tsplugin
24
+ languageOptions: {
25
+ parserOptions: {
26
+ ecmaFeatures: {
27
+ jsx: true,
28
+ },
29
+ },
30
30
  },
31
- },
32
- ...tseslint.configs.recommended.map((config) => ({
33
- ...config,
34
-
35
31
  settings: {
36
- react: {
32
+ 'import/resolver': {
33
+ node: {
34
+ extensions: [ '.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs' ],
35
+ },
36
+ },
37
+ 'react': {
37
38
  version: 'detect',
38
39
  },
39
40
  },
40
- ignores,
41
-
42
- rules: {
43
- ...config.rules,
44
- ...rules
45
- },
46
- })),
41
+ plugins,
42
+ rules,
43
+ }
47
44
  )
48
45
 
46
+ /**
47
+ * @summary ESLint configuration
48
+ * @description Opinionated yet functional AF base config for ESLint
49
+ * @author {@author}
50
+ * @version {@version}
51
+ **/
49
52
  export default config
package/index.mjs CHANGED
@@ -1,7 +1,17 @@
1
+ import tseslint from 'typescript-eslint'
2
+
1
3
  import config from './eslint.config.mjs'
2
4
 
5
+
6
+ const configType = tseslint.configs.base
7
+
3
8
  /**
4
9
  * @name config
5
- * @type {import('eslint').Linter.Config}
10
+ * @type {typeof configType}
6
11
  */
7
12
  export default config
13
+
14
+ export {
15
+ config,
16
+ configType
17
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tuomashatakka/eslint-config",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "Default eslint configuration",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
7
7
  "scripts": {
8
- "lint": "eslint . -c eslint.config.mjs"
8
+ "lint": "eslint . --config eslint.config.mjs"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
@@ -22,12 +22,13 @@
22
22
  "@eslint/js": ">=9.13.0",
23
23
  "react": "*",
24
24
  "@stylistic/eslint-plugin": "*",
25
- "typescript-eslint": "*"
25
+ "typescript-eslint": ">=8.1.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@eslint/compat": "^1.2.1",
29
29
  "@eslint/eslintrc": "^3.1.0",
30
30
  "@eslint/js": "^9.13.0",
31
+ "@eslint/config-array": "^1.5.3",
31
32
  "@stylistic/eslint-plugin": "^2.9.0",
32
33
  "@stylistic/eslint-plugin-ts": "^2.9.0",
33
34
  "@types/eslint__eslintrc": "^2.1.2",
package/rules.mjs CHANGED
@@ -1,19 +1,139 @@
1
+ /**
2
+ * @exports {import("eslint/rules").ESLintRules} rules
3
+ * @type {import("@eslint/core").RulesConfig}
4
+ */
5
+ export const rules = {
1
6
 
2
- const rules = {
3
-
7
+ // '@next/next/no-styled-jsx-in-document': [ 'error' ],
8
+ // '@next/next/no-sync-scripts': [ 'error' ],
4
9
  // 'block-padding/after-block': [ 'warn', 2 ],
5
10
 
11
+ // Comments
12
+ 'multiline-comment-style': [ 'warn', 'separate-lines', { checkJSDoc: false }],
13
+ '@stylistic/lines-around-comment': [ 'warn', {
14
+ beforeBlockComment: true,
15
+ beforeLineComment: true,
16
+ afterLineComment: false,
17
+ allowClassEnd: false,
18
+ allowBlockEnd: false,
19
+ }],
20
+
21
+ // TODO
22
+ 'import/no-extraneous-dependencies': [ 'warn' ],
23
+ 'import/consistent-type-specifier-style': [ 'warn', 'prefer-top-level' ],
24
+ 'import/newline-after-import': [ 'warn', { count: 2 }],
25
+ 'import/no-unassigned-import': [ 'error', { allow: [ '**/*.{le,c,sc,sa}ss' ]}],
26
+ 'import/prefer-default-export': [ 'error' ],
27
+ 'import/no-mutable-exports': [ 'error' ],
28
+ 'import/order': [ 'warn', {
29
+ 'groups': [ 'builtin', 'type', 'external', [ 'parent', 'sibling', 'index' ], 'internal', 'object' ],
30
+ 'alphabetize': { order: 'asc', caseInsensitive: true },
31
+ 'distinctGroup': true,
32
+ 'warnOnUnassignedImports': true,
33
+ 'newlines-between': 'always',
34
+ 'pathGroups': [
35
+ { group: 'internal', pattern: '**/*.css', position: 'after' },
36
+ { group: 'object', pattern: '**/*.scss' },
37
+ { group: 'parent', pattern: '@/**' },
38
+ { group: 'parent', pattern: '../**' },
39
+ { group: 'sibling', pattern: './**' }]}],
40
+
41
+ // Typescript
42
+ '@typescript-eslint/ban-ts-comment': [ 'off', 'allow-single-line' ],
43
+ '@typescript-eslint/no-unused-vars': [ 'warn' ],
44
+ '@typescript-eslint/no-explicit-any': [ 'warn' ],
45
+
46
+ // Enforced practices (enforce functional and orthogonal code)
47
+ 'complexity': [ 'warn', { max: 11 }],
48
+ 'eqeqeq': [ 'warn', 'smart' ],
49
+ 'arrow-body-style': [ 'warn', 'as-needed' ],
50
+ 'max-lines': [ 'warn', { max: 666, skipComments: true, skipBlankLines: true }],
51
+ 'max-statements': [ 'warn', 12 ],
52
+ 'max-depth': [ 'warn', 4 ],
53
+ 'no-console': [ 'warn' ],
54
+ 'no-debugger': [ 'warn' ],
55
+ 'dot-notation': [ 'warn' ],
56
+ 'no-undef': [ 'warn' ],
57
+ 'use-isnan': [ 'error' ],
58
+ 'no-obj-calls': [ 'error' ],
59
+ 'no-new-symbol': [ 'error' ],
60
+ 'no-func-assign': [ 'error' ],
61
+ 'no-class-assign': [ 'error' ],
62
+ 'no-array-constructor': [ 'error' ],
63
+
64
+ // Stylistic formatting opinionations
65
+ // '@stylistic/function-paren-newline': [ 'warn', 'always' ],
66
+ '@stylistic/function-call-spacing': [ 'warn', 'never' ],
67
+ '@stylistic/computed-property-spacing': [ 'warn', 'never' ],
68
+ '@stylistic/implicit-arrow-linebreak': [ 'warn', 'below' ],
69
+ '@stylistic/brace-style': [ 'warn', '1tbs', { allowSingleLine: false }],
70
+ '@stylistic/comma-dangle': [ 'warn', 'only-multiline' ],
71
+ '@stylistic/comma-spacing': [ 'warn', { before: false, after: true }],
72
+ '@stylistic/comma-style': [ 'warn', 'last' ],
73
+ '@stylistic/key-spacing': [ 'warn', { beforeColon: false, afterColon: true, align: 'value' }],
74
+ '@stylistic/keyword-spacing': [ 'warn', { before: true, after: true }],
75
+ '@stylistic/object-property-newline': [ 'warn', { allowAllPropertiesOnSameLine: true, allowMultiplePropertiesPerLine: false }],
76
+ '@stylistic/max-len': [ 'warn', 200 ],
77
+ '@stylistic/no-tabs': [ 'warn' ],
78
+ '@stylistic/no-extra-parens': [ 'warn', 'all' ],
79
+ '@stylistic/jsx-function-call-newline': [ 'warn', 'always' ],
80
+ '@stylistic/no-multiple-empty-lines': [ 'warn', { max: 2, maxEOF: 0, maxBOF: 0 }],
81
+ '@stylistic/no-trailing-spaces': [ 'warn', { skipBlankLines: false, ignoreComments: false }],
82
+ '@stylistic/no-confusing-arrow': [ 'warn', { allowParens: false, onlyOneSimpleParam: true }],
83
+ '@stylistic/no-whitespace-before-property': [ 'warn' ],
84
+ '@stylistic/space-in-parens': [ 'warn', 'never' ],
85
+ '@stylistic/space-infix-ops': [ 'warn', { int32Hint: false }],
86
+ '@stylistic/space-unary-ops': [ 'warn', { words: true, nonwords: false }],
87
+ '@stylistic/switch-colon-spacing': [ 'warn', { after: true, before: false }],
88
+ '@stylistic/template-curly-spacing': [ 'warn', 'never' ],
89
+ '@stylistic/wrap-iife': [ 'warn', 'inside' ],
90
+ '@stylistic/wrap-regex': [ 'warn' ],
91
+ '@stylistic/object-curly-spacing': [ 'warn', 'always', { arraysInObjects: false, objectsInObjects: false }],
92
+ '@stylistic/array-bracket-spacing': [ 'warn', 'always', { arraysInArrays: false, objectsInArrays: false }],
93
+ '@stylistic/new-parens': [ 'warn', 'always' ],
94
+ '@stylistic/jsx-closing-bracket-location': [ 'warn', 'tag-aligned' ],
95
+ '@stylistic/operator-linebreak': [ 'warn', 'after', { overrides: { '?': 'before', ':': 'before' }}],
96
+ '@stylistic/quote-props': [ 'warn', 'consistent-as-needed', { keywords: false, unnecessary: true, numbers: false }],
97
+ '@stylistic/indent': [ 'warn', 2, { SwitchCase: 1, CallExpression: { arguments: 'first' }}],
98
+ '@stylistic/arrow-spacing': [ 'warn' ],
99
+ '@stylistic/func-call-spacing': [ 'warn', 'never' ],
100
+ '@stylistic/newline-per-chained-call': [ 'warn', { ignoreChainWithDepth: 2 }],
101
+ '@stylistic/lines-between-class-members': [ 'warn', 'always', { exceptAfterSingleLine: true }],
102
+ '@stylistic/one-var-declaration-per-line': [ 'warn', 'always' ],
103
+
6
104
  // @stylistic
105
+ '@stylistic/arrow-parens': [ 'warn', 'always' ],
106
+ '@stylistic/dot-location': [ 'warn', 'property' ],
107
+ '@stylistic/eol-last': [ 'warn', 'always' ],
108
+ '@stylistic/multiline-ternary': [ 'warn', 'always-multiline' ],
109
+ '@stylistic/no-floating-decimal': [ 'warn' ],
110
+ '@stylistic/no-mixed-operators': [ 'warn' ],
111
+ '@stylistic/no-extra-semi': [ 'warn' ],
112
+ '@stylistic/semi-spacing': [ 'warn', { before: false, after: true }],
113
+ '@stylistic/semi-style': [ 'warn', 'last' ],
114
+ '@stylistic/semi': [ 'warn', 'never' ],
115
+ '@stylistic/space-before-function-paren': [ 'warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
116
+ '@stylistic/template-tag-spacing': [ 'warn', 'always' ],
117
+ '@stylistic/yield-star-spacing': [ 'warn', 'after' ],
118
+ '@stylistic/quotes': [ 'warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
119
+
120
+ // JSX/React
7
121
  '@stylistic/jsx-quotes': [ 'warn', 'prefer-single' ],
8
122
  '@stylistic/jsx-newline': [ 'warn', { prevent: true, allowMultilines: true }],
9
123
  '@stylistic/jsx-props-no-multi-spaces': [ 'warn' ],
124
+ '@stylistic/jsx-equals-spacing': [ 'warn', 'never' ],
125
+ '@stylistic/jsx-indent-props': [ 'warn', 2 ],
126
+ '@stylistic/jsx-max-props-per-line': [ 'warn', { maximum: 1, when: 'multiline' }],
127
+ '@stylistic/jsx-self-closing-comp': [ 'warn', { component: true, html: true }],
128
+ '@stylistic/jsx-one-expression-per-line': [ 'warn', { allow: 'single-child' }],
129
+ '@stylistic/jsx-tag-spacing': [ 'warn', { closingSlash: 'never', beforeSelfClosing: 'always', beforeClosing: 'never', afterOpening: 'never' }],
10
130
  'react/no-unescaped-entities': [ 'error', { forbid: [ '>', '}' ]}],
11
131
  'react/jsx-uses-vars': [ 'error' ],
12
132
  'react/jsx-uses-react': [ 'error' ],
13
133
  'react/style-prop-object': [ 'error', { allow: []}],
14
134
  'react/prefer-stateless-function': [ 'error', { ignorePureComponents: false }],
15
135
  'react/no-invalid-html-attribute': [ 'error', []],
16
- 'react/hook-use-state': [ 'warn', { allowDestructuredState: false }],
136
+ 'react/hook-use-state': [ 'warn', { allowDestructuredState: true }],
17
137
  'react/jsx-one-expression-per-line': [ 'warn', { allow: 'single-child' }],
18
138
  'react/jsx-no-useless-fragment': [ 'warn', { allowExpressions: true }],
19
139
  'react/jsx-no-target-blank': [ 'warn', { enforceDynamicLinks: 'always' }],
@@ -24,20 +144,6 @@ const rules = {
24
144
  'react/jsx-indent': [ 'warn', 2, { checkAttributes: true, indentLogicalExpressions: true }],
25
145
  'react/jsx-indent-props': [ 'warn', 2 ],
26
146
  'react/jsx-max-props-per-line': [ 'warn', { maximum: 1, when: 'multiline' }],
27
- '@stylistic/arrow-parens': [ 'warn', 'always' ],
28
- '@stylistic/dot-location': [ 'warn', 'property' ],
29
- '@stylistic/eol-last': [ 'warn', 'always' ],
30
- '@stylistic/multiline-ternary': [ 'warn', 'always-multiline' ],
31
- '@stylistic/no-extra-semi': [ 'warn' ],
32
- '@stylistic/no-floating-decimal': [ 'warn' ],
33
- '@stylistic/no-mixed-operators': [ 'warn' ],
34
- '@stylistic/semi-spacing': [ 'warn', { before: false, after: true }],
35
- '@stylistic/semi-style': [ 'warn', 'last' ],
36
- '@stylistic/semi': [ 'warn', 'never' ],
37
- '@stylistic/space-before-blocks': [ 'warn', 'always' ],
38
- '@stylistic/space-before-function-paren': [ 'warn', { anonymous: 'always', named: 'never', asyncArrow: 'always' }],
39
- '@stylistic/template-tag-spacing': [ 'warn', 'never' ],
40
- '@stylistic/yield-star-spacing': [ 'warn', 'after' ],
41
147
  'react/jsx-no-constructed-context-values': [ 'warn' ],
42
148
  'react/jsx-no-script-url': [ 'warn' ],
43
149
  'react/jsx-no-comment-textnodes': [ 'warn' ],
@@ -46,40 +152,37 @@ const rules = {
46
152
  'react/jsx-pascal-case': [ 'warn' ],
47
153
  'react/jsx-curly-brace-presence': [ 'warn', { props: 'never', children: 'never' }],
48
154
  'react/jsx-curly-spacing': [ 'warn', { when: 'never', children: true }],
49
- '@stylistic/jsx-equals-spacing': [ 'warn', 'never' ],
50
- '@stylistic/quotes': [ 'warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
51
- '@stylistic/jsx-indent-props': [ 'warn', 2 ],
52
- '@stylistic/jsx-max-props-per-line': [ 'warn', { maximum: 1, when: 'multiline' }],
53
- '@stylistic/jsx-self-closing-comp': [ 'warn', { component: true, html: true }],
54
- '@stylistic/jsx-one-expression-per-line': [ 'warn', { allow: 'single-child' }],
55
- '@stylistic/jsx-tag-spacing': [ 'warn', { closingSlash: 'never', beforeSelfClosing: 'never', beforeClosing: 'never', afterOpening: 'never' }],
56
155
  'react/display-name': [ 'warn', { checkContextObjects: true }],
57
156
 
58
- // Comments
59
- 'multiline-comment-style': [ 'warn', 'separate-lines', { checkJSDoc: false }],
60
- '@stylistic/lines-around-comment': [ 'warn', { beforeBlockComment: true, beforeLineComment: true, afterLineComment: false, allowClassEnd: false, allowBlockEnd: false
61
- }],
157
+ // Block padding
158
+ '@stylistic/no-multi-spaces': [ 'warn', { exceptions: { Property: true, TSTypeAnnotation: true, VariableDeclarator: true, ObjectExpression: false }}],
159
+ '@stylistic/spaced-comment': [ 'warn', 'always', { markers: [ '/' ]}],
160
+ '@stylistic/padded-blocks': [ 'warn', 'never' ],
161
+ '@stylistic/nonblock-statement-body-position': [ 'warn', 'below' ],
162
+ '@stylistic/space-before-blocks': [ 'warn', 'always' ],
163
+ '@stylistic/padding-line-between-statements': [
164
+ 'warn',
165
+ { blankLine: 'always', prev: 'directive', next: '*' },
166
+ { blankLine: 'any', prev: 'directive', next: 'directive' },
62
167
 
63
- // TODO
64
- 'import/no-extraneous-dependencies': [ 'warn' ],
65
- 'import/consistent-type-specifier-style': [ 'warn', 'prefer-top-level' ],
66
- 'import/newline-after-import': [ 'warn', { count: 2 }],
67
- 'import/no-unassigned-import': [ 'error', { allow: [ '**/*.{le,c,sc,sa}ss' ]}],
68
- 'import/prefer-default-export': [ 'error' ],
69
- 'import/no-mutable-exports': [ 'error' ],
168
+ { blankLine: 'always', next: [ 'const', 'let', 'var' ], prev: '*' },
169
+ { blankLine: 'any', prev: [ 'const', 'let', 'var' ], next: '*' },
170
+ { blankLine: 'any', prev: [ 'const', 'let', 'var' ], next: [ 'const', 'let', 'var' ]},
70
171
 
71
- 'import/order': [ 'warn', {
72
- 'groups': [ 'builtin', 'type', 'external', [ 'parent', 'sibling', 'index' ], 'internal', 'object' ],
73
- 'alphabetize': { order: 'asc', caseInsensitive: true },
74
- 'distinctGroup': true,
75
- 'warnOnUnassignedImports': true,
76
- 'newlines-between': 'always',
77
- 'pathGroups': [
78
- { group: 'internal', pattern: '**/*.css', position: 'after' },
79
- { group: 'object', pattern: '**/*.scss' },
80
- { group: 'parent', pattern: '@/**' },
81
- { group: 'parent', pattern: '../**' },
82
- { group: 'sibling', pattern: './**' }]}],
172
+ { prev: 'import', next: '*', blankLine: 'always' },
173
+ { prev: 'import', next: 'import', blankLine: 'any' },
174
+
175
+ { blankLine: 'always', prev: '*', next: [ 'export', 'return' ]},
176
+
177
+ { blankLine: 'never', prev: 'case', next: '*' },
178
+ { blankLine: 'never', prev: 'default', next: '*' },
179
+
180
+ { blankLine: 'always',
181
+ prev: '*',
182
+ next: [ 'multiline-expression', 'function', 'block-like', 'block' ]},
183
+ { blankLine: 'any',
184
+ prev: [ 'multiline-expression', 'function', 'block-like', 'block' ],
185
+ next: [ 'multiline-expression', 'function', 'block-like', 'block' ]}],
83
186
  }
84
187
 
85
188
  export default rules