Skip to content

Commit b4a432f

Browse files
authored
Merge pull request #19 from sparingsoftware/feat/FRN-173/add-new-eslint-rules
feat: Add new eslint rules FRN-173
2 parents 175c408 + 359c31c commit b4a432f

File tree

4 files changed

+77
-66
lines changed

4 files changed

+77
-66
lines changed

index.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/** @type {import("eslint").Linter.Config} */
22
const defaultConfig = {
3-
extends: ['plugin:@typescript-eslint/recommended', 'prettier'],
3+
extends: [
4+
'eslint:recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'prettier'
7+
],
48
plugins: ['import', 'unicorn'],
59
rules: {
610
'no-restricted-syntax': [
@@ -17,7 +21,6 @@ const defaultConfig = {
1721
'prefer-destructuring': ['warn', { object: false, array: true }],
1822
'no-multiple-empty-lines': ['error', { max: 2 }],
1923
'object-shorthand': ['warn', 'always'],
20-
'unicorn/prefer-ternary': 'warn',
2124
'import/newline-after-import': ['warn', { count: 1 }],
2225
'import/order': [
2326
'warn',
@@ -56,7 +59,27 @@ const defaultConfig = {
5659
assertionStyle: 'as',
5760
objectLiteralTypeAssertions: 'allow-as-parameter'
5861
}
59-
]
62+
],
63+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
64+
'unicorn/prefer-ternary': 'warn',
65+
'unicorn/prefer-negative-index': 'warn',
66+
'unicorn/prefer-at': 'warn',
67+
'unicorn/prefer-switch': 'warn',
68+
'unicorn/switch-case-braces': ['warn', 'avoid'],
69+
'unicorn/consistent-destructuring': 'warn',
70+
'unicorn/no-useless-undefined': 'warn',
71+
'unicorn/expiring-todo-comments': 'warn',
72+
'unicorn/require-array-join-separator': 'warn'
73+
},
74+
/*
75+
Rule @typescript-eslint/prefer-nullish-coalescing - require parserOptions reason:
76+
Error while loading rule '@typescript-eslint/prefer-nullish-coalescing':
77+
You have used a rule which requires parserServices to be generated.
78+
You must therefore provide a value for the "parserOptions.project"
79+
*/
80+
parserOptions: {
81+
parser: '@typescript-eslint/parser',
82+
project: true
6083
}
6184
}
6285

package-lock.json

Lines changed: 42 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
"@vue/eslint-config-typescript": "^13.0.0",
3939
"eslint-config-prettier": "^9.1.0",
4040
"eslint-import-resolver-babel-module": "^5.3.2",
41-
"eslint-plugin-import": "^2.29.1",
4241
"eslint-plugin-prettier": "^5.1.3",
4342
"eslint-plugin-react-hooks": "^4.6.0",
43+
"eslint-plugin-vue": "^9.25.0",
4444
"eslint-plugin-unicorn": "^52.0.0",
45-
"eslint-plugin-vue": "^9.25.0"
45+
"eslint-plugin-import": "^2.29.1"
4646
},
4747
"devDependencies": {
4848
"@commitlint/cli": "^19.2.2",

vue.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ const defaultConfig = require('./index')
44
const vue = {
55
extends: [
66
'plugin:vue/vue3-recommended',
7-
'eslint:recommended',
87
'@sparing-software/eslint-config',
98
'@vue/eslint-config-typescript/recommended'
109
],
10+
/*
11+
This parser safe us from extra eslint problem after
12+
adding @typescript-eslint/prefer-nullish-coalescing flag into index.js
13+
https://stackoverflow.com/a/66598327
14+
*/
15+
parser: 'vue-eslint-parser',
1116
parserOptions: {
17+
...defaultConfig.parserOptions,
1218
ecmaVersion: 'latest'
1319
},
1420
rules: {

0 commit comments

Comments
 (0)