Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit bdb9758

Browse files
refactor(ts-es-lint): add typescript es-lint plugin and rules, commitizen and supported browsers
1 parent 90e0570 commit bdb9758

11 files changed

+913
-152
lines changed

.browserslistrc

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
> 1%
2-
last 2 versions
1+
> 0.75% and not dead and not op_mob > 0 and not baidu > 0
2+
ie >= 10
3+
safari >= 10.1
4+
edge > 17

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
shims-tsx.d.ts
2+
shims-vue.d.ts
3+
jest.config.js
4+
babel.config.js
5+
postcss.config.js

.eslintrc.js

+102-43
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,118 @@
1+
const esLintRules = {
2+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
3+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
4+
'no-alert': process.env.NODE_ENV === 'production' ? 'error' : 'off',
5+
'no-template-curly-in-string': 'error',
6+
'require-atomic-updates': 'error',
7+
curly: ['error', 'all'],
8+
eqeqeq: 'error',
9+
'no-eval': 'error',
10+
'require-await': 'error',
11+
strict: ['error', 'global'],
12+
'no-restricted-imports': ['error', { patterns: ['**/dist/*'] }],
13+
indent: 'off',
14+
'no-empty-function': 'off',
15+
'no-unused-vars': 'off',
16+
'no-extra-parens': 'off',
17+
'no-unused-expressions': 'off'
18+
};
19+
20+
const tsLintRules = {
21+
'@typescript-eslint/indent': 'off',
22+
'@typescript-eslint/explicit-member-accessibility': [
23+
'error',
24+
{ overrides: { methods: 'no-public', properties: 'off' } }
25+
],
26+
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'@typescript-eslint/no-use-before-define': ['off', { functions: false }],
29+
'@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
30+
'@typescript-eslint/no-empty-function': ['error', { allow: ['protected-constructors'] }],
31+
'@typescript-eslint/no-parameter-properties': ['error', { allows: ['private', 'protected'] }],
32+
'@typescript-eslint/no-empty-interface': 'off',
33+
'@typescript-eslint/no-object-literal-type-assertion': 'off',
34+
'@typescript-eslint/no-extra-parens': ['error', 'all', { nestedBinaryExpressions: false }],
35+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
36+
'@typescript-eslint/no-unused-expressions': ['error'],
37+
// Type information rules
38+
'@typescript-eslint/no-unused-vars-experimental': 'error',
39+
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
40+
'@typescript-eslint/prefer-optional-chain': 'error',
41+
'@typescript-eslint/prefer-nullish-coalescing': 'error'
42+
};
43+
44+
const vuePluginRules = {
45+
'vue/attribute-hyphenation': 'off',
46+
'vue/attributes-order': [
47+
'error',
48+
{
49+
order: [
50+
'DEFINITION',
51+
'CONDITIONALS',
52+
'LIST_RENDERING',
53+
'UNIQUE',
54+
'RENDER_MODIFIERS',
55+
'TWO_WAY_BINDING',
56+
'OTHER_DIRECTIVES',
57+
'CONTENT',
58+
'EVENTS',
59+
'GLOBAL',
60+
'OTHER_ATTR'
61+
]
62+
}
63+
],
64+
'vue/no-v-html': 'off',
65+
'vue/eqeqeq': 'error',
66+
'vue/v-on-function-call': 'error'
67+
};
68+
69+
const importPluginRules = {
70+
'import/no-self-import': 'error',
71+
'import/no-unresolved': ['error', { ignore: ['^@.*'] }]
72+
};
73+
74+
const jestPluginRules = {
75+
'jest/expect-expect': ['error', { assertFunctionNames: ['expect*'] }],
76+
'jest/lowercase-name': ['error', { ignore: ['test'] }],
77+
'jest/no-duplicate-hooks': 'error',
78+
'jest/no-expect-resolves': 'error',
79+
'jest/no-test-return-statement': 'error',
80+
'jest/prefer-hooks-on-top': 'error',
81+
'jest/require-top-level-describe': 'error',
82+
'jest/valid-title': 'error'
83+
};
84+
85+
186
module.exports = {
287
root: true,
3-
env: {
4-
node: true
88+
env: { node: true },
89+
parserOptions: {
90+
parser: '@typescript-eslint/parser',
91+
project: './tsconfig.json', // required for rules that need type information
92+
extraFileExtensions: ['.vue']
593
},
694
extends: [
7-
'plugin:vue/recommended',
95+
'eslint:recommended',
96+
'plugin:@typescript-eslint/eslint-recommended',
97+
'plugin:@typescript-eslint/recommended',
98+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
899
'plugin:prettier/recommended',
100+
'plugin:vue/recommended',
9101
'plugin:import/errors',
10102
'plugin:import/warnings',
11103
'plugin:import/typescript',
104+
'plugin:jest/recommended',
105+
'plugin:jest/style',
12106
'@vue/prettier',
13107
'@vue/typescript'
14108
],
15109
rules: {
16-
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
17-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
18-
'no-alert': process.env.NODE_ENV === 'production' ? 'error' : 'off',
19110
'prettier/prettier': 'error',
20-
'vue/attribute-hyphenation': 'off',
21-
'vue/attributes-order': [
22-
'error',
23-
{
24-
order: [
25-
'DEFINITION',
26-
'CONDITIONALS',
27-
'LIST_RENDERING',
28-
'UNIQUE',
29-
'RENDER_MODIFIERS',
30-
'TWO_WAY_BINDING',
31-
'OTHER_DIRECTIVES',
32-
'CONTENT',
33-
'EVENTS',
34-
'GLOBAL',
35-
'OTHER_ATTR'
36-
]
37-
}
38-
],
39-
'vue/no-v-html': 'off',
40-
'vue/arrow-spacing': 'error',
41-
'vue/eqeqeq': 'error',
42-
'vue/v-on-function-call': 'error',
43-
'no-extra-parens': 'error',
44-
'no-template-curly-in-string': 'error',
45-
'require-atomic-updates': 'error',
46-
curly: ['error', 'all'],
47-
eqeqeq: 'error',
48-
'no-eval': 'error',
49-
'require-await': 'error',
50-
strict: ['error', 'global'],
51-
'no-restricted-imports': ['error', { patterns: ['**/dist/*'] }],
52-
'import/no-self-import': 'error',
53-
'import/no-unresolved': ['error', { ignore: ['^@.*'] }]
54-
},
55-
parserOptions: {
56-
parser: '@typescript-eslint/parser'
111+
...esLintRules,
112+
...tsLintRules,
113+
...vuePluginRules,
114+
...importPluginRules,
115+
...jestPluginRules
57116
},
58117
overrides: [
59118
{

.versionrc

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"header": "# Empathy Vue Carousel",
3+
"types": [
4+
{"type": "feat", "section": "Features"},
5+
{"type": "fix", "section": "Bug Fixes"},
6+
{"type": "docs", "section": "Documentation"},
7+
{"type": "style", "section":"Styling"},
8+
{"type": "refactor", "section":"Code Refactoring"},
9+
{"type": "test", "section":"Testing"},
10+
{"type": "improvement", "section": "Feature Improvements"},
11+
{"type": "perf", "section":"Performance Improvements"},
12+
{"type": "build", "section":"Build System"},
13+
{"type": "chore", "section":"Others", "hidden": true},
14+
{"type": "revert", "section":"Reverts", "hidden": true}
15+
]
16+
}

0 commit comments

Comments
 (0)