Skip to content

Commit deada0a

Browse files
committed
chore: udpate lint, close #6896
1 parent 418d8b3 commit deada0a

16 files changed

+93
-228
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ es/
77
lib/
88
_site/
99
dist/
10+
site/dist/
1011
components/version/version.tsx
12+
site/src/router/demoRoutes.js

.eslintrc.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@ module.exports = {
1515
'plugin:vue/vue3-recommended',
1616
'plugin:import/recommended',
1717
'plugin:import/typescript',
18-
'prettier',
18+
'@vue/typescript/recommended',
19+
'@vue/prettier',
20+
// 'prettier',
1921
],
22+
// extends: [
23+
// 'eslint:recommended',
24+
// 'plugin:vue/vue3-recommended',
25+
// '@vue/typescript/recommended',
26+
// '@vue/prettier',
27+
// ],
2028
plugins: ['markdown', 'jest', '@typescript-eslint', 'import'],
29+
globals: {
30+
defineProps: 'readonly',
31+
},
2132
overrides: [
2233
{
2334
files: ['*.md'],
@@ -28,12 +39,11 @@ module.exports = {
2839
},
2940
{
3041
files: ['*.ts', '*.tsx'],
31-
extends: ['@vue/typescript/recommended', '@vue/prettier', '@vue/prettier/@typescript-eslint'],
42+
// extends: ['@vue/typescript/recommended', '@vue/prettier'],
3243
parserOptions: {
3344
project: './tsconfig.json',
3445
},
3546
rules: {
36-
'@typescript-eslint/no-explicit-any': 0,
3747
'@typescript-eslint/ban-types': 0,
3848
'@typescript-eslint/consistent-type-imports': 'error',
3949
'@typescript-eslint/explicit-module-boundary-types': 0,
@@ -51,17 +61,21 @@ module.exports = {
5161
parser: 'vue-eslint-parser',
5262
parserOptions: {
5363
parser: '@typescript-eslint/parser',
64+
ecmaVersion: 2021,
5465
},
5566
rules: {
5667
'no-console': 'off',
57-
'@typescript-eslint/no-unused-vars': [
58-
'error',
59-
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true },
60-
],
68+
'vue/no-reserved-component-names': 'off',
6169
},
6270
},
6371
],
6472
rules: {
73+
'@typescript-eslint/no-explicit-any': 0,
74+
'@typescript-eslint/no-empty-function': 0,
75+
'@typescript-eslint/no-unused-vars': [
76+
'error',
77+
{ vars: 'all', args: 'after-used', ignoreRestSiblings: true, argsIgnorePattern: '^_' },
78+
],
6579
'import/no-named-as-default': 'off',
6680
'import/namespace': [2, { allowComputed: true }],
6781
'import/no-named-as-default-member': 'off',

components/_util/BaseMixin.js renamed to components/_util/BaseMixin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getOptionProps } from './props-util';
33

44
export default {
55
methods: {
6-
setState(state = {}, callback) {
6+
setState(state = {}, callback: () => any) {
77
let newState = typeof state === 'function' ? state(this.$data, this.$props) : state;
88
if (this.getDerivedStateFromProps) {
99
const s = this.getDerivedStateFromProps(getOptionProps(this), {
@@ -26,6 +26,7 @@ export default {
2626
},
2727
__emit() {
2828
// 直接调用事件,底层组件不需要vueTool记录events
29+
// eslint-disable-next-line prefer-rest-params
2930
const args = [].slice.call(arguments, 0);
3031
let eventName = args[0];
3132
eventName = `on${eventName[0].toUpperCase()}${eventName.substring(1)}`;

components/_util/antInputDirective.js renamed to components/_util/antInputDirective.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
function onCompositionStart(e) {
1+
import type { Directive } from 'vue';
2+
3+
function onCompositionStart(e: any) {
24
e.target.composing = true;
35
}
46

5-
function onCompositionEnd(e) {
7+
function onCompositionEnd(e: any) {
68
// prevent triggering an input event for no reason
79
if (!e.target.composing) return;
810
e.target.composing = false;
@@ -15,10 +17,15 @@ function trigger(el, type) {
1517
el.dispatchEvent(e);
1618
}
1719

18-
export function addEventListener(el, event, handler, options) {
20+
export function addEventListener(
21+
el: HTMLElement,
22+
event: string,
23+
handler: EventListenerOrEventListenerObject,
24+
options?: boolean | AddEventListenerOptions,
25+
) {
1926
el.addEventListener(event, handler, options);
2027
}
21-
const antInput = {
28+
const antInput: Directive = {
2229
created(el, binding) {
2330
if (!binding.modifiers || !binding.modifiers.lazy) {
2431
addEventListener(el, 'compositionstart', onCompositionStart);

components/_util/json2mq.js renamed to components/_util/json2mq.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
* https://github.com/akiran/json2mq.git
44
*/
55

6-
const camel2hyphen = function (str) {
6+
const camel2hyphen = function (str: string) {
77
return str
88
.replace(/[A-Z]/g, function (match) {
99
return '-' + match.toLowerCase();
1010
})
1111
.toLowerCase();
1212
};
1313

14-
const isDimension = function (feature) {
14+
const isDimension = function (feature: string) {
1515
const re = /[height|width]$/;
1616
return re.test(feature);
1717
};
1818

19-
const obj2mq = function (obj) {
19+
const obj2mq = function (obj: { [x: string]: any }) {
2020
let mq = '';
2121
const features = Object.keys(obj);
2222
features.forEach(function (feature, index) {
@@ -40,7 +40,7 @@ const obj2mq = function (obj) {
4040
return mq;
4141
};
4242

43-
export default function (query) {
43+
export default function (query: any[]) {
4444
let mq = '';
4545
if (typeof query === 'string') {
4646
return query;

0 commit comments

Comments
 (0)