eslint-config-tamia 9.0.2 → 9.1.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.
package/Readme.md CHANGED
@@ -12,9 +12,11 @@ We export three ESLint configurations:
12
12
 
13
13
  ### eslint-config-tamia
14
14
 
15
- Our default export contains all of our ESLint rules, including EcmaScript 6+. It requires `eslint`.
15
+ Base set of rules for JavaScript. Includes:
16
16
 
17
- `npm install --save-dev eslint-config-tamia eslint`
17
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
18
+
19
+ `npm install --save-dev eslint eslint-config-tamia`
18
20
 
19
21
  `eslint.config.mjs`:
20
22
 
@@ -25,9 +27,12 @@ export default [...tamia];
25
27
 
26
28
  ### eslint-config-tamia/react
27
29
 
28
- Lints ES6+ and React. Uses `eslint-plugin-react`.
30
+ Lints ES6+ and React. Includes:
31
+
32
+ - [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react)
33
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
29
34
 
30
- `npm install --save-dev eslint-config-tamia eslint`
35
+ `npm install --save-dev eslint eslint-config-tamia`
31
36
 
32
37
  `eslint.config.mjs`:
33
38
 
@@ -38,9 +43,12 @@ export default [...tamiaReact];
38
43
 
39
44
  ### eslint-config-tamia/typescript
40
45
 
41
- Lints TypeScript. Uses `typescript-eslint`.
46
+ Lints TypeScript. Includes:
42
47
 
43
- `npm install --save-dev eslint-config-tamia eslint`
48
+ - [typescript-eslint](https://typescript-eslint.io/)
49
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
50
+
51
+ `npm install --save-dev eslint eslint-config-tamia`
44
52
 
45
53
  `eslint.config.mjs`:
46
54
 
@@ -51,9 +59,13 @@ export default [...tamiaTypeScript];
51
59
 
52
60
  ### eslint-config-tamia/typescript-react
53
61
 
54
- Lints TypeScript and React. Uses `typescript-eslint` and `eslint-plugin-react`.
62
+ Lints TypeScript and React. Includes:
63
+
64
+ - [typescript-eslint](https://typescript-eslint.io/)
65
+ - [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react)
66
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
55
67
 
56
- `npm install --save-dev eslint-config-tamia eslint`
68
+ `npm install --save-dev eslint eslint-config-tamia`
57
69
 
58
70
  `eslint.config.mjs`:
59
71
 
@@ -62,19 +74,6 @@ import tamiaTypeScriptReact from 'eslint-config-tamia/typescript-react';
62
74
  export default [...tamiaTypeScriptReact];
63
75
  ```
64
76
 
65
- ### eslint-config-tamia/legacy
66
-
67
- Lints ES5 and below. Only requires `eslint`.
68
-
69
- `npm install --save-dev eslint-config-tamia eslint`
70
-
71
- `eslint.config.mjs`:
72
-
73
- ```js
74
- import tamiaTypeScript from 'eslint-config-tamia/typescript';
75
- export default [...tamiaTypeScript];
76
- ```
77
-
78
77
  ## Code style at a glance
79
78
 
80
79
  - ~~Tab indentation.~~
package/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import legacy from './legacy.mjs';
2
- import es6 from './rules/es6.mjs';
3
- import strict from './rules/strict.mjs';
1
+ import javascript from './rules/javascript.mjs';
2
+ import unicorn from './rules/unicorn.mjs';
4
3
 
5
4
  /** @type { import("eslint").Linter.FlatConfig[] } */
6
- export default [...legacy, ...es6, ...strict];
5
+ export default [...javascript, ...unicorn];
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "eslint-config-tamia",
3
3
  "description": "Tâmia ESLint config",
4
- "version": "9.0.2",
4
+ "version": "9.1.0",
5
5
  "type": "module",
6
- "main": "index.js",
6
+ "main": "index.mjs",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.mjs"
10
+ },
11
+ "./react": "./react.mjs",
12
+ "./typescript-react": "./typescript.mjs-react",
13
+ "./typescript": "./typescript.mjs"
14
+ },
7
15
  "files": [
8
16
  "rules",
9
17
  "*.mjs"
package/react.mjs CHANGED
@@ -1,22 +1,6 @@
1
- import legacy from './rules/legacy.mjs';
2
- import es6 from './rules/es6.mjs';
3
- import strict from './rules/strict.mjs';
1
+ import javascript from './rules/javascript.mjs';
4
2
  import react from './rules/react.mjs';
3
+ import unicorn from './rules/unicorn.mjs';
5
4
 
6
5
  /** @type { import("eslint").Linter.FlatConfig[] } */
7
- export default [
8
- ...legacy,
9
- ...es6,
10
- ...strict,
11
- ...react,
12
- {
13
- languageOptions: {
14
- parserOptions: {
15
- ecmaVersion: 2024,
16
- sourceType: 'module',
17
- requireConfigFile: false,
18
- },
19
- },
20
- rules: {},
21
- },
22
- ];
6
+ export default [...javascript, ...react, ...unicorn];
@@ -1,13 +1,21 @@
1
+ import globals from 'globals';
2
+ import js from '@eslint/js';
3
+
1
4
  /** @type { import("eslint").Linter.FlatConfig[] } */
2
5
  export default [
6
+ js.configs.recommended,
3
7
  {
8
+ files: ['**/*.{js,mjs,cjs,jsx,astro}'],
9
+ languageOptions: {
10
+ globals: {
11
+ ...globals.es2024,
12
+ ...globals.browser,
13
+ ...globals.node,
14
+ },
15
+ },
4
16
  rules: {
5
17
  // Enforces return statements in callbacks of array’s methods
6
18
  'array-callback-return': 'error',
7
- // Treat var statements as if they were block scoped
8
- 'block-scoped-var': 'error',
9
- // Require return statements to either always or never specify values
10
- 'consistent-return': 'error',
11
19
  // Require curly braces for all control statements
12
20
  curly: ['error', 'all'],
13
21
  // Encourages use of dot notation whenever possible
@@ -21,31 +29,12 @@ export default [
21
29
  eqeqeq: ['error', 'allow-null'],
22
30
  // Disallow the use of alert, confirm, and prompt
23
31
  'no-alert': 'error',
24
- // Disallow using an async function as a Promise executor
25
- 'no-async-promise-executor': 'error',
26
- // Disallow use of arguments.caller or arguments.callee
27
- 'no-caller': 'error',
28
- // Disallow else after a return in an if
29
- 'no-else-return': 'off',
30
- // Disallow use of eval()
31
- 'no-eval': 'error',
32
32
  // Disallow adding to native types
33
33
  'no-extend-native': 'error',
34
34
  // Disallow unnecessary function binding
35
35
  'no-extra-bind': 'error',
36
- // Disallow the use of leading or trailing decimal points in numeric literals
37
- 'no-floating-decimal': 'error',
38
36
  // Disallow the type conversions with shorter notations
39
- 'no-implicit-coercion': [
40
- 'error',
41
- {
42
- boolean: false,
43
- number: true,
44
- string: true,
45
- },
46
- ],
47
- // Disallow use of eval()-like methods
48
- 'no-implied-eval': 'error',
37
+ 'no-implicit-coercion': 'error',
49
38
  // Disallow usage of __iterator__ property
50
39
  'no-iterator': 'error',
51
40
  // Disallow use of labels for anything other then loops and switches
@@ -60,12 +49,8 @@ export default [
60
49
  'no-lone-blocks': 'error',
61
50
  // Disallow creation of functions within loops
62
51
  'no-loop-func': 'error',
63
- // Disallow characters which are made with multiple code points in character class syntax
64
- 'no-misleading-character-class': 'error',
65
52
  // Disallow use of multiline strings
66
53
  'no-multi-str': 'error',
67
- // Disallow use of new operator for Function object
68
- 'no-new-func': 'error',
69
54
  // Disallows creating new instances of String, Number, and Boolean
70
55
  'no-new-wrappers': 'error',
71
56
  // Disallow use of octal escape sequences in string literals, such as var foo = 'Copyright \251';
@@ -88,8 +73,6 @@ export default [
88
73
  'no-unused-expressions': 'error',
89
74
  // Disallow unnecessary .call() and .apply()
90
75
  'no-useless-call': 'error',
91
- // Disallow unnecessary catch clauses
92
- 'no-useless-catch': 'error',
93
76
  // Disallow unnecessary concatenation of literals or template literals
94
77
  'no-useless-concat': 'error',
95
78
  // Disallow redundant return statements
@@ -101,8 +84,6 @@ export default [
101
84
  allowAsStatement: true,
102
85
  },
103
86
  ],
104
- // Disallow use of the with statement
105
- 'no-with': 'error',
106
87
  // Disallow async functions which have no await expression
107
88
  'require-await': 'error',
108
89
  // Require or disallow Yoda conditions
@@ -113,6 +94,63 @@ export default [
113
94
  exceptRange: true,
114
95
  },
115
96
  ],
97
+ // Disallow duplicate imports
98
+ 'no-duplicate-imports': 'error',
99
+ // Disallow unnecessary constructor
100
+ 'no-useless-constructor': 'error',
101
+ // Disallow unnecessary computed property keys on objects
102
+ 'no-useless-computed-key': 'error',
103
+ // Require let or const instead of var
104
+ 'no-var': 'error',
105
+ // Require method and property shorthand syntax for object literals
106
+ 'object-shorthand': ['error', 'always'],
107
+ // Suggest using of const declaration for variables that are never modified after declared
108
+ 'prefer-const': 'error',
109
+ // Suggest using the spread operator instead of .apply()
110
+ 'prefer-spread': 'error',
111
+ // Suggest using the rest parameters instead of arguments
112
+ 'prefer-rest-params': 'error',
113
+ // Disallow renaming import, export, and destructured assignments to the same name
114
+ 'no-useless-rename': 'error',
115
+ // Limits the number of parameters that can be used in the function declaration
116
+ 'max-params': [0, 5],
117
+ // Strict is implied in ECMAScript modules
118
+ strict: ['error', 'never'],
119
+ // Require camel case names
120
+ camelcase: [
121
+ 'error',
122
+ {
123
+ properties: 'never',
124
+ },
125
+ ],
126
+ // Disallow mixed 'LF' and 'CRLF' as linebreaks
127
+ 'linebreak-style': ['error', 'unix'],
128
+ // Require a capital letter for constructors
129
+ 'new-cap': [
130
+ 'error',
131
+ {
132
+ newIsCap: true,
133
+ capIsNew: false,
134
+ },
135
+ ],
136
+ // Disallow use of the Array constructor
137
+ 'no-array-constructor': 'error',
138
+ // Disallow if as the only statement in an else block
139
+ 'no-lonely-if': 'error',
140
+ // Disallow use of the Object constructor
141
+ 'no-new-object': 'error',
142
+ // Disallow Use of Chained Assignment Expressions
143
+ 'no-multi-assign': 'error',
144
+ // Disallow the use of Boolean literals in conditional expressions
145
+ 'no-unneeded-ternary': 'error',
146
+ // Disallow use of undefined when initializing variables
147
+ 'no-undef-init': 'error',
148
+ // Disallow variable declarations from shadowing variables declared in the outer scope
149
+ 'no-shadow': 'warn',
150
+ // Allow just one var statement per variable
151
+ 'one-var': ['error', 'never'],
152
+ // Disallow the Unicode Byte Order Mark (BOM)
153
+ 'unicode-bom': ['error', 'never'],
116
154
  },
117
155
  },
118
156
  ];
package/rules/react.mjs CHANGED
@@ -1,14 +1,16 @@
1
+ import globals from 'globals';
1
2
  import react from 'eslint-plugin-react';
2
3
 
3
4
  /** @type { import("eslint").Linter.FlatConfig[] } */
4
5
  export default [
5
6
  {
6
- plugins: { react },
7
+ files: ['**/*.{js,jsx,mjs,cjs,tsx}'],
8
+ ...reactPlugin.configs.flat.recommended,
7
9
  languageOptions: {
8
- parserOptions: {
9
- ecmaFeatures: {
10
- jsx: true,
11
- },
10
+ ...reactPlugin.configs.flat.recommended.languageOptions,
11
+ globals: {
12
+ ...globals.es2024,
13
+ ...globals.browser,
12
14
  },
13
15
  },
14
16
  settings: {
@@ -19,175 +21,47 @@ export default [
19
21
  // View link below for react rules documentation
20
22
  // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules
21
23
  rules: {
22
- // Prevent missing displayName in a React component definition
23
- 'react/display-name': 0,
24
- // Forbid certain propTypes (any, array, object)
25
- 'react/forbid-prop-types': 0,
26
24
  // Enforce boolean attributes notation in JSX
27
- 'react/jsx-boolean-value': [2, 'never'],
28
- // Validate closing bracket location in JSX
29
- 'react/jsx-closing-bracket-location': 0,
30
- // Enforce or disallow spaces inside of curly braces in JSX attributes
31
- 'react/jsx-curly-spacing': 0,
32
- // Disallow spaces around equal signs in JSX attributes
33
- 'react/jsx-equals-spacing': 0,
25
+ 'react/jsx-boolean-value': ['error', 'never'],
34
26
  // Enforce event handler naming conventions in JSX
35
27
  'react/jsx-handler-names': [
36
- 2,
28
+ 'error',
37
29
  {
38
30
  eventHandlerPrefix: 'handle',
39
31
  eventHandlerPropPrefix: 'on',
40
32
  },
41
33
  ],
42
- // Validate JSX indentation
43
- 'react/jsx-indent': 0,
44
- // Validate props indentation in JSX
45
- 'react/jsx-indent-props': 0,
46
34
  // Validate JSX has key prop when in array or iterator
47
- 'react/jsx-key': 2,
48
- // Limit maximum of props on a single line in JSX
49
- 'react/jsx-max-props-per-line': 0,
35
+ 'react/jsx-key': 'error',
50
36
  // Prevent usage of .bind() and arrow functions in JSX props
51
37
  'react/jsx-no-bind': [
52
- 2,
38
+ 'error',
53
39
  {
54
40
  allowArrowFunctions: true,
55
41
  },
56
42
  ],
57
- // Prevent duplicate props in JSX
58
- 'react/jsx-no-duplicate-props': [
59
- 2,
60
- {
61
- ignoreCase: false,
62
- },
63
- ],
64
- // Prevent usage of unwrapped JSX strings
65
- 'react/jsx-no-literals': 0,
66
- // Prevent usage of unsafe target='_blank'
67
- 'react/jsx-no-target-blank': 2,
68
- // Disallow undeclared variables in JSX
69
- 'react/jsx-no-undef': 2,
70
43
  // Enforce PascalCase for user-defined JSX components
71
- 'react/jsx-pascal-case': 2,
72
- // Enforce propTypes declarations alphabetical sorting
73
- 'react/jsx-sort-prop-types': 0,
74
- // Enforce props alphabetical sorting
75
- 'react/jsx-sort-props': 0,
76
- // Prevent React to be incorrectly marked as unused
77
- 'react/jsx-uses-react': 2,
78
- // Prevent variables used in JSX to be incorrectly marked as unused
79
- 'react/jsx-uses-vars': 2,
80
- // Prevent usage of dangerous JSX properties
81
- 'react/no-danger': 0,
82
- // Prevent usage of deprecated methods
83
- 'react/no-deprecated': 2,
84
- // Prevent usage of setState in componentDidMount
85
- 'react/no-did-mount-set-state': 2,
86
- // Prevent usage of setState in componentDidUpdate
87
- 'react/no-did-update-set-state': 2,
88
- // Prevent direct mutation of this.state
89
- 'react/no-direct-mutation-state': 2,
90
- // Prevent usage of isMounted
91
- 'react/no-is-mounted': 2,
92
- // Prevent multiple component definition per file
93
- 'react/no-multi-comp': [
94
- 2,
95
- {
96
- ignoreStateless: true,
97
- },
98
- ],
99
- // Prevent usage of setState
100
- 'react/no-set-state': 0,
101
- // Prevent using string references
102
- 'react/no-string-refs': 2,
103
- // Prevent usage of unknown DOM property
104
- 'react/no-unknown-property': 2,
44
+ 'react/jsx-pascal-case': 'error',
105
45
  // Require ES6 class declarations over React.createClass
106
- 'react/prefer-es6-class': [2, 'always'],
46
+ 'react/prefer-es6-class': ['error', 'always'],
107
47
  // Enforce stateless React Components to be written as a pure function
108
- 'react/prefer-stateless-function': 2,
109
- // Prevent missing props validation in a React component definition
110
- 'react/prop-types': [
111
- 2,
112
- {
113
- ignore: [],
114
- customValidators: [],
115
- },
116
- ],
117
- // Prevent missing React when using JSX
118
- 'react/react-in-jsx-scope': 2,
48
+ 'react/prefer-stateless-function': 'error',
119
49
  // Prevent extra closing tags for components without children
120
50
  'react/self-closing-comp': [
121
- 2,
51
+ 'error',
122
52
  {
123
53
  component: true,
124
54
  html: false,
125
55
  },
126
56
  ],
127
- // Enforce component methods order
128
- 'react/sort-comp': [
129
- 2,
130
- {
131
- order: [
132
- 'static-variables',
133
- 'instance-variables',
134
- 'lifecycle',
135
- 'everything-else',
136
- 'render',
137
- ],
138
- groups: {
139
- lifecycle: [
140
- 'constructor',
141
- 'getDefaultProps',
142
- 'getInitialState',
143
- 'getChildContext',
144
- 'getDerivedStateFromProps',
145
- 'componentWillMount',
146
- 'UNSAFE_componentWillMount',
147
- 'componentDidMount',
148
- 'componentWillReceiveProps',
149
- 'UNSAFE_componentWillReceiveProps',
150
- 'shouldComponentUpdate',
151
- 'componentWillUpdate',
152
- 'UNSAFE_componentWillUpdate',
153
- 'getSnapshotBeforeUpdate',
154
- 'componentDidUpdate',
155
- 'componentDidCatch',
156
- 'componentWillUnmount',
157
- ],
158
- },
159
- },
160
- ],
161
- // Prevent missing parentheses around multilines JSX
162
- 'react/jsx-wrap-multilines': 0,
163
- // Restrict file extensions that may contain JSX
164
- 'react/jsx-filename-extension': 0,
165
- // Prevent usage of the return value of React.render
166
- 'react/no-render-return-value': 2,
167
- // Prevent comments from being inserted as text nodes
168
- 'react/jsx-no-comment-textnodes': 2,
169
- // Prevent usage of findDOMNode
170
- 'react/no-find-dom-node': 2,
171
- // Prevent problem with children and props.dangerouslySetInnerHTML
172
- 'react/no-danger-with-children': 2,
173
- // Prevent passing of children as props
174
- 'react/no-children-prop': 2,
175
- // Prevent invalid characters from appearing in markup
176
- 'react/no-unescaped-entities': 2,
177
- // Configure the position of the first property
178
- 'react/jsx-first-prop-new-line': 0,
179
- // Validate whitespace in and around the JSX opening and closing brackets
180
- 'react/jsx-tag-spacing': 0,
181
57
  // Prevent void DOM elements (e.g. <img />, <br />) from receiving children
182
- 'react/void-dom-elements-no-children': 2,
58
+ 'react/void-dom-elements-no-children': 'error',
183
59
  // Enforce style prop value being an object
184
- 'react/style-prop-object': 2,
60
+ 'react/style-prop-object': 'error',
185
61
  // Prevent usage of setState in componentWillUpdate
186
- 'react/no-will-update-set-state': 2,
187
- // Enforce all defaultProps have a corresponding non-required PropType
188
- 'react/default-props-match-prop-types': 2,
62
+ 'react/no-will-update-set-state': 'error',
189
63
  // Prevents common typos
190
- 'react/no-typos': 2,
64
+ 'react/no-typos': 'error',
191
65
  },
192
66
  },
193
67
  ];
@@ -2,12 +2,27 @@ import tseslint from 'typescript-eslint';
2
2
 
3
3
  /** @type { import("eslint").Linter.FlatConfig[] } */
4
4
  export default [
5
- tseslint.configs.base,
5
+ ...tseslint.configs.recommended,
6
6
  {
7
+ files: ['**/*.{ts,tsx,astro}'],
7
8
  rules: {
9
+ // Disable generic rules that conflict with TypeScript
10
+ camelcase: 'off',
11
+ 'no-array-constructor': 'off',
12
+ 'no-unused-vars': 'off',
13
+ 'no-unused-expressions': 'off',
14
+ 'no-use-before-define': 'off',
15
+ 'no-shadow': 'off',
16
+ // Conflicts with TypeScript check for unreachable code
17
+ 'consistent-return': 'off',
18
+ // Checked by TypeScript - ts(2367)
19
+ 'valid-typeof': 'off',
20
+
21
+ // Require that function overload signatures be consecutive
8
22
  '@typescript-eslint/adjacent-overload-signatures': 'error',
23
+ // Require consistently using either T[] or Array<T> for arrays
9
24
  '@typescript-eslint/array-type': 'error',
10
- '@typescript-eslint/ban-types': 'error',
25
+ // Enforce naming conventions for everything across a codebase
11
26
  '@typescript-eslint/naming-convention': [
12
27
  'error',
13
28
  {
@@ -35,61 +50,20 @@ export default [
35
50
  leadingUnderscore: 'allow',
36
51
  },
37
52
  ],
53
+ // Require explicit accessibility modifiers on class properties and methods
38
54
  '@typescript-eslint/explicit-member-accessibility': 'error',
55
+ // Enforce consistent usage of type assertions
39
56
  '@typescript-eslint/consistent-type-assertions': 'error',
40
- '@typescript-eslint/no-array-constructor': 'error',
41
- '@typescript-eslint/no-empty-interface': 'error',
57
+ // Disallow explicit type declarations for variables or parameters
58
+ // initialized to a number, string, or boolean
42
59
  '@typescript-eslint/no-inferrable-types': 'error',
43
- '@typescript-eslint/no-misused-new': 'error',
44
- '@typescript-eslint/no-namespace': 'error',
60
+ // Disallow non-null assertions using the ! postfix operator
45
61
  '@typescript-eslint/no-non-null-assertion': 'error',
46
- '@typescript-eslint/triple-slash-reference': 'error',
47
- '@typescript-eslint/no-unused-vars': 'warn',
62
+ // Disallow unused expressions
48
63
  '@typescript-eslint/no-unused-expressions': 'error',
49
- '@typescript-eslint/no-use-before-define': 'error',
50
- '@typescript-eslint/no-var-requires': 'error',
64
+ // Disallow variable declarations from shadowing variables declared
65
+ // in the outer scope
51
66
  '@typescript-eslint/no-shadow': 'error',
52
- '@typescript-eslint/prefer-namespace-keyword': 'error',
53
67
  },
54
- overrides: [
55
- {
56
- files: ['*.ts', '*.tsx', '*.astro'],
57
- rules: {
58
- // Disable generic rules that conflict with TypeScript
59
- camelcase: 'off',
60
- 'no-array-constructor': 'off',
61
- 'no-unused-vars': 'off',
62
- 'no-unused-expressions': 'off',
63
- 'no-use-before-define': 'off',
64
- 'no-shadow': 'off',
65
-
66
- // Conflicts with TypeScript check for unreachable code
67
- 'consistent-return': 'off',
68
-
69
- //Checked by TypeScript - ts(2378)
70
- 'getter-return': 'off',
71
- // Checked by TypeScript - ts(2300)
72
- 'no-dupe-args': 'off',
73
- // Checked by TypeScript - ts(1117)
74
- 'no-dupe-keys': 'off',
75
- // Checked by TypeScript - ts(7027)
76
- 'no-unreachable': 'off',
77
- // Checked by TypeScript - ts(2367)
78
- 'valid-typeof': 'off',
79
- // Checked by TypeScript - ts(2588)
80
- 'no-const-assign': 'off',
81
- // Checked by TypeScript - ts(2588)
82
- 'no-new-symbol': 'off',
83
- // Checked by TypeScript - ts(2376)
84
- 'no-this-before-super': 'off',
85
- // This is checked by TypeScript using the option `strictNullChecks`.
86
- 'no-undef': 'off',
87
- // This is already checked by TypeScript.
88
- 'no-dupe-class-members': 'off',
89
- // This is already checked by TypeScript.
90
- 'no-redeclare': 'off',
91
- },
92
- },
93
- ],
94
68
  },
95
69
  ];
@@ -0,0 +1,11 @@
1
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn';
2
+
3
+ export default [
4
+ eslintPluginUnicorn.configs['flat/recommended'],
5
+ {
6
+ rules: {
7
+ // Reduces readability
8
+ 'unicorn/prefer-ternary': 'off',
9
+ },
10
+ },
11
+ ];
@@ -1,14 +1,7 @@
1
+ import javascript from './rules/javascript.mjs';
1
2
  import typescript from './rules/typescript.mjs';
2
3
  import react from './rules/react.mjs';
4
+ import unicorn from './rules/unicorn.mjs';
3
5
 
4
6
  /** @type { import("eslint").Linter.FlatConfig[] } */
5
- export default [
6
- ...typescript,
7
- ...react,
8
- {
9
- rules: {
10
- // Disable generic rules that conflict with TypeScript
11
- 'react/prop-types': 'off',
12
- },
13
- },
14
- ];
7
+ export default [...javascript, ...typescript, ...react, ...unicorn];
package/typescript.mjs CHANGED
@@ -1,7 +1,6 @@
1
- import legacy from './rules/legacy.mjs';
2
- import es6 from './rules/es6.mjs';
3
- import strict from './rules/strict.mjs';
1
+ import javascript from './rules/javascript.mjs';
4
2
  import typescript from './rules/typescript.mjs';
3
+ import unicorn from './rules/unicorn.mjs';
5
4
 
6
5
  /** @type { import("eslint").Linter.FlatConfig[] } */
7
- export default [...legacy, ...es6, ...strict, ...typescript];
6
+ export default [...javascript, ...typescript, ...unicorn];
package/legacy.mjs DELETED
@@ -1,26 +0,0 @@
1
- import js from '@eslint/js';
2
- import globals from 'globals';
3
- import bestPractices from './rules/best-practices.mjs';
4
- import errors from './rules/errors.mjs';
5
- import legacy from './rules/legacy.mjs';
6
- import node from './rules/node.mjs';
7
- import style from './rules/style.mjs';
8
- import variables from './rules/variables.mjs';
9
-
10
- /** @type { import("eslint").Linter.FlatConfig[] } */
11
- export default [
12
- js.configs.recommended,
13
- ...bestPractices,
14
- ...errors,
15
- ...legacy,
16
- ...node,
17
- ...style,
18
- ...variables,
19
- {
20
- languageOptions: {
21
- globals: {
22
- ...globals.browser,
23
- },
24
- },
25
- },
26
- ];
package/rules/errors.mjs DELETED
@@ -1,13 +0,0 @@
1
- /** @type { import("eslint").Linter.FlatConfig[] } */
2
- export default [
3
- {
4
- // Most of possible error rules are inherited from eslint:recommended preset
5
- rules: {
6
- // Enforce “for” loop update clause moving the counter
7
- // in the right direction
8
- 'for-direction': 2,
9
- // Disallow use of Object.prototypes builtins directly
10
- 'no-prototype-builtins': 2,
11
- },
12
- },
13
- ];
package/rules/es6.mjs DELETED
@@ -1,37 +0,0 @@
1
- import globals from 'globals';
2
-
3
- /** @type { import("eslint").Linter.FlatConfig[] } */
4
- export default [
5
- {
6
- languageOptions: {
7
- parserOptions: {
8
- ecmaVersion: 2024,
9
- sourceType: 'module',
10
- requireConfigFile: false,
11
- },
12
- globals: {
13
- ...globals.es2024,
14
- },
15
- },
16
- rules: {
17
- // Disallow duplicate imports
18
- 'no-duplicate-imports': 2,
19
- // Disallow unnecessary constructor
20
- 'no-useless-constructor': 2,
21
- // Disallow unnecessary computed property keys on objects
22
- 'no-useless-computed-key': 2,
23
- // Require let or const instead of var
24
- 'no-var': 2,
25
- // Require method and property shorthand syntax for object literals
26
- 'object-shorthand': [2, 'always'],
27
- // Suggest using of const declaration for variables that are never modified after declared
28
- 'prefer-const': 2,
29
- // Suggest using the spread operator instead of .apply()
30
- 'prefer-spread': 2,
31
- // Suggest using the rest parameters instead of arguments
32
- 'prefer-rest-params': 2,
33
- // Disallow renaming import, export, and destructured assignments to the same name
34
- 'no-useless-rename': 2,
35
- },
36
- },
37
- ];
package/rules/legacy.mjs DELETED
@@ -1,17 +0,0 @@
1
- /** @type { import("eslint").Linter.FlatConfig[] } */
2
- export default [
3
- {
4
- rules: {
5
- // Specify the maximum depth that blocks can be nested
6
- 'max-depth': [0, 5],
7
- // Limits the number of parameters that can be used in the function declaration
8
- 'max-params': [0, 5],
9
- // Specify the maximum number of statement allowed in a function
10
- 'max-statements': [0, 500],
11
- // Disallow use of bitwise operators
12
- 'no-bitwise': 0,
13
- // Disallow use of unary operators, ++ and --
14
- 'no-plusplus': 0,
15
- },
16
- },
17
- ];
package/rules/node.mjs DELETED
@@ -1,16 +0,0 @@
1
- import globals from 'globals';
2
-
3
- /** @type { import("eslint").Linter.FlatConfig[] } */
4
- export default [
5
- {
6
- languageOptions: {
7
- globals: {
8
- ...globals.node,
9
- },
10
- },
11
- rules: {
12
- // Disallow string concatenation with __dirname and __filename
13
- 'no-path-concat': 2,
14
- },
15
- },
16
- ];
package/rules/strict.mjs DELETED
@@ -1,9 +0,0 @@
1
- /** @type { import("eslint").Linter.FlatConfig[] } */
2
- export default [
3
- {
4
- rules: {
5
- // Strict is implied in ECMAScript modules
6
- strict: [2, 'never'],
7
- },
8
- },
9
- ];
package/rules/style.mjs DELETED
@@ -1,41 +0,0 @@
1
- /** @type { import("eslint").Linter.FlatConfig[] } */
2
- export default [
3
- {
4
- // Code style should be handled by Prettier
5
- rules: {
6
- // Require camel case names
7
- camelcase: [
8
- 2,
9
- {
10
- properties: 'never',
11
- },
12
- ],
13
- // Disallow mixed 'LF' and 'CRLF' as linebreaks
14
- 'linebreak-style': [2, 'unix'],
15
- // Require a capital letter for constructors
16
- 'new-cap': [
17
- 2,
18
- {
19
- newIsCap: true,
20
- capIsNew: false,
21
- },
22
- ],
23
- // Disallow use of the Array constructor
24
- 'no-array-constructor': 2,
25
- // Disallow if as the only statement in an else block
26
- 'no-lonely-if': 2,
27
- // Disallow use of the Object constructor
28
- 'no-new-object': 2,
29
- // Disallow Use of Chained Assignment Expressions
30
- 'no-multi-assign': 2,
31
- // Disallow the use of Boolean literals in conditional expressions
32
- 'no-unneeded-ternary': 2,
33
- // Allow just one var statement per variable
34
- 'one-var': [2, 'never'],
35
- // Disallow the Unicode Byte Order Mark (BOM)
36
- 'unicode-bom': [2, 'never'],
37
- // Disallow mixed spaces and tabs (disabled because of Prettier)
38
- 'no-mixed-spaces-and-tabs': 0,
39
- },
40
- },
41
- ];
@@ -1,15 +0,0 @@
1
- /** @type { import("eslint").Linter.FlatConfig[] } */
2
- export default [
3
- {
4
- rules: {
5
- // Disallow shadowing of names such as arguments
6
- 'no-shadow-restricted-names': 2,
7
- // Disallow use of undefined when initializing variables
8
- 'no-undef-init': 2,
9
- // Disallow variable redeclaration
10
- 'no-redeclare': 2,
11
- // Disallow variable declarations from shadowing variables declared in the outer scope
12
- 'no-shadow': 1,
13
- },
14
- },
15
- ];