@lidofinance/eslint-config 0.0.0 → 0.0.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.
@@ -23,7 +23,7 @@ const loosenReactRules = {
23
23
  'react/react-in-jsx-scope': 'off',
24
24
  }
25
25
 
26
- module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules, reactRules, defaultRules }) {
26
+ module.exports = function buildConfig(env, { nextRules, tsRules, reactRules, defaultRules }) {
27
27
  const config = {
28
28
  extends: ['eslint:recommended'],
29
29
  env: {
@@ -107,7 +107,6 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
107
107
 
108
108
  if (env.typescript) {
109
109
  let tsconfigPath
110
- const extraTsRules = {}
111
110
 
112
111
  try {
113
112
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -115,6 +114,7 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
115
114
  // eslint-disable-next-line @typescript-eslint/unbound-method
116
115
  const { config } = ts.readConfigFile(tsconfigPath, ts.sys.readFile)
117
116
  if (config) {
117
+ // this are type-aware checks that require tsconfig presence
118
118
  Object.assign(tsRules, {
119
119
  '@typescript-eslint/await-thenable': 'warn',
120
120
  '@typescript-eslint/no-floating-promises': 'error',
@@ -124,12 +124,12 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
124
124
  '@typescript-eslint/no-unnecessary-type-assertion': 'warn',
125
125
  'require-await': 'off',
126
126
  '@typescript-eslint/require-await': 'error',
127
- '@typescript-eslint/restrict-plus-operands': 'warn',
128
127
  '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
129
128
  })
130
129
  }
131
- if (config.compilerOptions?.strict) {
132
- Object.assign(extraTsRules, {
130
+ if (config?.compilerOptions?.strict) {
131
+ Object.assign(tsRules, {
132
+ '@typescript-eslint/restrict-plus-operands': 'warn',
133
133
  '@typescript-eslint/no-explicit-any': 'error',
134
134
  '@typescript-eslint/no-unsafe-argument': 'error',
135
135
  '@typescript-eslint/no-unsafe-assignment': 'error',
@@ -166,7 +166,6 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
166
166
  rules: {
167
167
  ...config.rules,
168
168
  ...tsRules,
169
- ...extraTsRules,
170
169
  },
171
170
  overrides: [
172
171
  ...config.overrides,
@@ -176,9 +175,6 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
176
175
  {
177
176
  files: ['*.stories.ts', '*.stories.tsx', '*.stories.mts', '*.stories.cts'],
178
177
  rules: {
179
- ...config.rules,
180
- ...tsDisableRules,
181
- ...tsRules,
182
178
  ...loosenRules,
183
179
  },
184
180
  },
@@ -199,16 +195,13 @@ module.exports = function buildConfig(env, { nextRules, tsDisableRules, tsRules,
199
195
  },
200
196
  rules: {
201
197
  ...loosenRules,
202
- ...config.rules,
203
- ...tsDisableRules,
204
- ...tsRules,
205
198
  'jest/no-deprecated-functions': 'off',
206
199
  },
207
200
  },
208
201
  {
209
202
  files: ['*.ts', '*.tsx', '*.mts', '*.cts'],
210
203
  rules: {
211
- ...tsDisableRules,
204
+ ...tsRules,
212
205
  },
213
206
  },
214
207
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lidofinance/eslint-config",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "main": "auto.js",
5
5
  "license": "unlicensed (yet)",
6
6
  "dependencies": {
package/rulesets/easy.js CHANGED
@@ -2,8 +2,14 @@
2
2
  const defaultRules = {
3
3
  'prefer-const': 'warn',
4
4
  'no-useless-escape': 'warn',
5
- 'no-unused-vars': ['error', { ignoreRestSiblings: true }],
5
+ 'no-unused-vars': ['error', {
6
+ ignoreRestSiblings: true,
7
+ args: "all",
8
+ argsIgnorePattern: "^_"
9
+ }],
10
+ 'no-shadow': 'error',
6
11
  'no-empty-function': 'off',
12
+ 'no-void': 'off',
7
13
  'promise/no-return-wrap': 'error',
8
14
  'promise/param-names': 'warn',
9
15
  // analysis/correctness
@@ -17,6 +23,8 @@ const defaultRules = {
17
23
  'import/no-named-as-default-member': 'off',
18
24
  'import/no-duplicates': 'off',
19
25
  'import/no-extraneous-dependencies': 'error',
26
+ "import/extensions": "off",
27
+ "import/prefer-default-export": "off",
20
28
  'sonarjs/max-switch-cases': 'error',
21
29
  'sonarjs/no-all-duplicated-branches': 'error',
22
30
  'sonarjs/no-collapsible-if': 'error',
@@ -113,7 +121,7 @@ const nextRules = {
113
121
  '@next/next/no-before-interactive-script-outside-document': 'warn',
114
122
  '@next/next/no-assign-module-variable': 'error',
115
123
  }
116
- const tsDisableRules = {
124
+ const tsRules = {
117
125
  'import/named': 'off', // https://github.com/import-js/eslint-plugin-import/blob/main/config/typescript.js#L29
118
126
  'constructor-super': 'off', // ts(2335) & ts(2377)
119
127
  'getter-return': 'off', // ts(2378)
@@ -136,8 +144,6 @@ const tsDisableRules = {
136
144
  'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
137
145
  'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
138
146
  'valid-typeof': 'off', // ts(2367)
139
- }
140
- const tsRules = {
141
147
  '@typescript-eslint/adjacent-overload-signatures': 'error',
142
148
  '@typescript-eslint/ban-ts-comment': 'error',
143
149
  '@typescript-eslint/ban-types': 'error',
@@ -161,6 +167,10 @@ const tsRules = {
161
167
  '@typescript-eslint/no-unnecessary-type-constraint': 'warn',
162
168
  'no-unused-vars': 'off',
163
169
  '@typescript-eslint/no-unused-vars': defaultRules['no-unused-vars'],
170
+ 'no-shadow': 'off',
171
+ '@typescript-eslint/no-shadow': defaultRules['no-shadow'],
172
+ 'default-case': 'off',
173
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
164
174
  '@typescript-eslint/prefer-as-const': 'error',
165
175
  '@typescript-eslint/prefer-namespace-keyword': 'error',
166
176
  '@typescript-eslint/triple-slash-reference': 'error',
@@ -195,7 +205,6 @@ const reactRules = {
195
205
 
196
206
  module.exports = {
197
207
  nextRules,
198
- tsDisableRules,
199
208
  tsRules,
200
209
  reactRules,
201
210
  defaultRules,
package/rulesets/hard.js CHANGED
@@ -1,10 +1,9 @@
1
- const { nextRules, tsDisableRules, tsRules, reactRules, defaultRules } = require('./easy')
1
+ const { nextRules, tsRules, reactRules, defaultRules } = require('./easy')
2
2
 
3
3
  module.exports = {
4
4
  nextRules: {
5
5
  ...nextRules,
6
6
  },
7
- tsDisableRules,
8
7
  tsRules,
9
8
  reactRules: {
10
9
  ...reactRules,