Skip to content

Commit 1d49507

Browse files
authored
chore: move to ESLint Flat Config (#3003)
* chore: move to ESLint Flat Config * fix: add gitignore
1 parent 35984c0 commit 1d49507

File tree

184 files changed

+1508
-996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+1508
-996
lines changed

.editorconfig

-12
This file was deleted.

.eslintrc

-7
This file was deleted.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ pnpm-debug.log*
3939

4040
# vitest
4141
/html
42+
43+
# packages/nutui-taro-demo
44+
/packages/nutui-taro-demo/src/app.config.ts

eslint.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import NutUI from '@nutui/eslint-config'
2+
import gitignore from 'eslint-config-flat-gitignore'
3+
4+
export default [
5+
gitignore(),
6+
...NutUI
7+
]

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
"test": "vitest",
5656
"test:ui": "vitest --ui --coverage",
5757
"test:c": "vitest --coverage",
58-
"lint": "eslint ./src ./packages/**/src --ext .vue,.ts,.tsx,.js,.jsx",
58+
"lint": "eslint ./src ./packages/**/src",
5959
"lint:fix": "pnpm lint --fix",
60+
"lint:ui": "pnpm eslint-config-inspector",
6061
"copydocs": "node ./scripts/copymd.cjs",
6162
"attrs": "node ./scripts/createAttributes.cjs",
6263
"attrs:taro": "node ./scripts/createAttributes.cjs taro",
@@ -80,6 +81,8 @@
8081
"devDependencies": {
8182
"@commitlint/cli": "^19.2.1",
8283
"@commitlint/config-conventional": "^19.1.0",
84+
"@eslint/config-inspector": "^0.1.0",
85+
"@eslint/eslintrc": "^3.0.2",
8386
"@nutui/eslint-config": "workspace:*",
8487
"@nutui/prettier-plugin": "workspace:*",
8588
"@nutui/vite-plugins": "workspace:*",
@@ -94,6 +97,7 @@
9497
"autoprefixer": "^10.4.19",
9598
"codesandbox": "^2.2.3",
9699
"eslint": "^8.57.0",
100+
"eslint-config-flat-gitignore": "^0.1.3",
97101
"fs-extra": "^11.2.0",
98102
"happy-dom": "^14.3.9",
99103
"husky": "^9.0.11",
@@ -116,7 +120,7 @@
116120
"node": "^18.0.0 || >=20.0.0"
117121
},
118122
"nano-staged": {
119-
"*.{ts,tsx,js,jsx,vue,scss,md}": "prettier --write",
123+
"*.{css,scss,md}": "prettier --write",
120124
"*.{ts,tsx,js,jsx,vue}": "eslint --fix"
121125
},
122126
"repository": {

packages/nutui-eslint-config/index.js

+60-42
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,64 @@
1-
module.exports = {
2-
extends: ['plugin:vue/base', 'eslint:recommended', 'plugin:vue/vue3-recommended', 'prettier'],
3-
parser: 'vue-eslint-parser',
4-
parserOptions: {
5-
parser: '@typescript-eslint/parser',
6-
ecmaVersion: 2020,
7-
sourceType: 'module',
8-
ecmaFeatures: {
9-
jsx: true
1+
import pluginJs from '@eslint/js'
2+
import pluginVue from 'eslint-plugin-vue'
3+
import pluginTs from 'typescript-eslint'
4+
import stylistic from '@stylistic/eslint-plugin'
5+
6+
import parserVue from 'vue-eslint-parser'
7+
import parserTs from '@typescript-eslint/parser'
8+
9+
export default [
10+
pluginJs.configs.recommended,
11+
stylistic.configs.customize({
12+
quoteProps: 'as-needed',
13+
commaDangle: 'never',
14+
braceStyle: '1tbs'
15+
}),
16+
...pluginTs.configs.recommended,
17+
...pluginVue.configs['flat/recommended'],
18+
{
19+
rules: {
20+
// typescript-eslint
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'@typescript-eslint/ban-types': 'off',
23+
'@typescript-eslint/no-var-requires': 'off',
24+
'no-unused-vars': 'off',
25+
'@typescript-eslint/no-unused-vars': 'error',
26+
'@typescript-eslint/ban-ts-comment': 'off',
27+
// eslint-plugin-vue
28+
'vue/v-on-event-hyphenation': [
29+
'error',
30+
'always',
31+
{
32+
autofix: true
33+
}
34+
],
35+
'vue/no-v-html': 'off',
36+
'vue/max-attributes-per-line': 'off',
37+
'vue/first-attribute-linebreak': 'off',
38+
'vue/multi-word-component-names': 'off',
39+
'vue/no-v-text-v-html-on-component': 'off',
40+
// TODO: will be removed
41+
'vue/html-self-closing': 'off',
42+
'vue/html-closing-bracket-newline': 'off',
43+
'vue/singleline-html-element-content-newline': 'off'
1044
}
1145
},
12-
plugins: ['vue', '@typescript-eslint'],
13-
env: {
14-
es6: true,
15-
node: true,
16-
browser: true,
17-
jest: true
18-
},
19-
globals: {
20-
vi: true,
21-
NodeJS: true,
22-
TaroGeneral: true
23-
},
24-
rules: {
25-
// basic
26-
semi: [2, 'never'],
27-
// @typescript-eslint
28-
'@typescript-eslint/no-explicit-any': 'off',
29-
'@typescript-eslint/ban-types': 'off',
30-
'@typescript-eslint/no-var-requires': 'off',
31-
'no-unused-vars': 'off',
32-
'@typescript-eslint/no-unused-vars': 'error',
33-
// eslint-plugin-vue
34-
'vue/v-on-event-hyphenation': [
35-
'error',
36-
'always',
37-
{
38-
autofix: true
46+
{
47+
languageOptions: {
48+
parser: parserVue,
49+
globals: {
50+
vi: true,
51+
NodeJS: true,
52+
TaroGeneral: true
53+
},
54+
parserOptions: {
55+
parser: parserTs,
56+
ecmaVersion: 2020,
57+
sourceType: 'module',
58+
ecmaFeatures: {
59+
jsx: true
60+
}
3961
}
40-
],
41-
'vue/no-v-html': 'off',
42-
'vue/first-attribute-linebreak': 'off',
43-
'vue/multi-word-component-names': 'off',
44-
'vue/no-v-text-v-html-on-component': 'off'
62+
}
4563
}
46-
}
64+
]

packages/nutui-eslint-config/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"jdf2e"
1010
],
1111
"author": "jdf2e",
12+
"type": "module",
1213
"license": "MIT",
1314
"main": "index.js",
1415
"publishConfig": {
@@ -24,11 +25,13 @@
2425
"url": "https://github.com/jdf2e/nutui/issues"
2526
},
2627
"dependencies": {
28+
"@stylistic/eslint-plugin": "^1.7.0",
2729
"@typescript-eslint/eslint-plugin": "^7.4.0",
2830
"@typescript-eslint/parser": "^7.4.0",
29-
"eslint-config-prettier": "^9.1.0",
3031
"eslint-plugin-vue": "^9.24.0",
31-
"vue-eslint-parser": "^9.4.2"
32+
"typescript-eslint": "^7.4.0",
33+
"vue-eslint-parser": "^9.4.2",
34+
"@eslint/js": "^8.57.0"
3235
},
3336
"devDependencies": {
3437
"eslint": "^8.57.0"

packages/nutui-playground/src/store.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export class NutUIStore extends ReplStore {
101101
this.state.mainFile = CONTAINER_FILE
102102
this.setActive(APP_FILE)
103103
}
104+
104105
serialize() {
105106
const files = this.getFiles()
106107
delete files[IMPORTMAP_FILE]
@@ -109,11 +110,12 @@ export class NutUIStore extends ReplStore {
109110
delete files[INSTALL_FILE.replace('src/', '')]
110111
return '#' + utoa(JSON.stringify(files))
111112
}
113+
112114
setNutUIVersion(v: string) {
113115
style.value = `https://cdn.jsdelivr.net/npm/@nutui/nutui@${v}/dist/style.css`
114116
const install = new File(INSTALL_FILE, installCode.value, true)
115117
this.addFile(install)
116-
compileFile(this, install).then((errs) => this.state.errors.push(...errs))
118+
compileFile(this, install).then(errs => this.state.errors.push(...errs))
117119
this.setImportMap({
118120
imports: {
119121
'@nutui/nutui': `https://cdn.jsdelivr.net/npm/@nutui/nutui@${v}/dist/nutui.js`,

packages/nutui-taro-demo/src/business/pages/address/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ const showSelected = () => {
244244
const onChange = (cal: CalBack, tag: string) => {
245245
const name = (address as any)[cal.next]
246246
if (name?.length < 1) {
247-
;(showPopup as any)[tag] = false
247+
(showPopup as any)[tag] = false
248248
}
249249
}
250250
const close1 = (val: CalResult) => {

packages/nutui-taro-demo/src/business/pages/category/index.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
<h2>只显示文字</h2>
99
<nut-category :category="data.category" @change="changeText">
10-
<nut-category-pane type="text" :category-child="data.categoryChild2" @on-change="onChange"> </nut-category-pane
11-
></nut-category>
10+
<nut-category-pane type="text" :category-child="data.categoryChild2" @on-change="onChange"> </nut-category-pane>
11+
</nut-category>
1212

1313
<h2>自定义分类</h2>
14-
<nut-category
15-
><nut-category-pane type="custom" :custom-category="customCategory" @on-change="changeCustom"> </nut-category-pane
16-
></nut-category>
14+
<nut-category>
15+
<nut-category-pane type="custom" :custom-category="customCategory" @on-change="changeCustom"> </nut-category-pane>
16+
</nut-category>
1717
</Demo>
1818
</template>
1919

packages/nutui-taro-demo/src/business/pages/comment/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ const getData = () => {
7979
method: 'GET',
8080
url: 'https://storage.360buyimg.com/nutui/3x/comment_data.json',
8181
success: (res) => {
82-
res.data.Comment.info.avatar =
83-
'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png'
82+
res.data.Comment.info.avatar
83+
= 'https://img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png'
8484
cmt.value = res.data.Comment
8585
}
8686
})

packages/nutui-taro-demo/src/business/pages/timeselect/basic.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const onChange = (pannelKey) => {
4242
}
4343
4444
const onSelect = (item) => {
45-
let curTimeIndex = time.value[0]['list'].findIndex((time) => time === item)
45+
let curTimeIndex = time.value[0]['list'].findIndex(time => time === item)
4646
if (curTimeIndex === -1) {
4747
time.value[0]['list'].push(item)
4848
} else {

packages/nutui-taro-demo/src/business/pages/timeselect/multiple.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const times = ref([
3434
3535
const onChange = (pannelKey) => {
3636
key.value = pannelKey
37-
const curTime = time.value.find((item) => item.key == pannelKey)
37+
const curTime = time.value.find(item => item.key == pannelKey)
3838
if (!curTime) {
3939
time.value.push({
4040
key: pannelKey,
@@ -44,8 +44,8 @@ const onChange = (pannelKey) => {
4444
}
4545
4646
const onSelect = (item) => {
47-
let findIndex = time.value.findIndex((item) => item.key == key.value)
48-
let curTimeIndex = time.value[findIndex]['list'].findIndex((time) => time === item)
47+
let findIndex = time.value.findIndex(item => item.key == key.value)
48+
let curTimeIndex = time.value[findIndex]['list'].findIndex(time => time === item)
4949
if (curTimeIndex === -1) {
5050
time.value[findIndex]['list'].push(item)
5151
} else {

packages/nutui-taro-demo/src/business/pages/timeselect/title.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const onChange = (pannelKey) => {
4343
}
4444
4545
const onSelect = (item) => {
46-
let curTimeIndex = time.value[0]['list'].findIndex((time) => time === item)
46+
let curTimeIndex = time.value[0]['list'].findIndex(time => time === item)
4747
if (curTimeIndex === -1) {
4848
time.value[0]['list'].push(item)
4949
} else {

packages/nutui-taro-demo/src/components/header.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import config from '@/packages/../config.json'
1919
2020
const isH5 = Taro.getEnv() === Taro.ENV_TYPE.WEB
2121
22-
//返回demo页
22+
// 返回demo页
2323
const navigateTo = () => {
2424
Taro.navigateBack()
2525
}

packages/nutui-taro-demo/src/dentry/pages/calendar/multiple.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ import { ref } from 'vue'
1616
const show = ref(false)
1717
const date = ref([])
1818
const choose = (param) => {
19-
date.value = param.map((item) => item[3])
19+
date.value = param.map(item => item[3])
2020
}
2121
</script>

packages/nutui-taro-demo/src/dentry/pages/checkbox/methods.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<template>
22
<nut-cell>
33
<nut-checkbox-group ref="group" v-model="state.checkboxgroup3" @change="changeBox4">
4-
<nut-checkbox v-for="item in state.checkboxsource" :key="item.label" :label="item.label">{{
5-
item.value
6-
}}</nut-checkbox>
4+
<nut-checkbox v-for="item in state.checkboxsource" :key="item.label" :label="item.label">
5+
{{
6+
item.value
7+
}}
8+
</nut-checkbox>
79
</nut-checkbox-group>
810
</nut-cell>
911
<nut-cell>

packages/nutui-taro-demo/src/dentry/pages/datepicker/filter.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const confirm = ({ selectedValue }) => {
1919
}
2020
const filter = (type, options) => {
2121
if (type === 'hour') {
22-
return options.filter((option) => Number(option.value) % 6 === 0)
22+
return options.filter(option => Number(option.value) % 6 === 0)
2323
}
2424
return options
2525
}

packages/nutui-taro-demo/src/dentry/pages/input/format.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
import { ref } from 'vue'
77
const val1 = ref('')
88
const val2 = ref('')
9-
const formatter = (value) => value.replace(/\d/g, '')
9+
const formatter = value => value.replace(/\d/g, '')
1010
</script>

packages/nutui-taro-demo/src/dentry/pages/uploader/index.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
:status="progressPercentage == 100 ? '' : 'active'"
2424
>
2525
</nut-progress>
26-
<!--
26+
<!--
2727
album 从相册选图
2828
camera 使用相机
2929
environment 使用后置摄像头(仅H5纯浏览器)
@@ -123,7 +123,7 @@ const clearUpload = () => {
123123
}
124124
125125
const beforeXhrUpload = (taroUploadFile: any, options: any) => {
126-
//taroUploadFile 是 Taro.uploadFile , 你也可以自定义设置其它函数
126+
// taroUploadFile 是 Taro.uploadFile , 你也可以自定义设置其它函数
127127
const uploadTask = taroUploadFile({
128128
url: options.url,
129129
filePath: options.taroFilePath,
@@ -134,7 +134,7 @@ const beforeXhrUpload = (taroUploadFile: any, options: any) => {
134134
}, //
135135
formData: options.formData,
136136
name: options.name,
137-
success(response: { errMsg: any; statusCode: number; data: string }) {
137+
success(response: { errMsg: any, statusCode: number, data: string }) {
138138
if (options.xhrState == response.statusCode) {
139139
options.onSuccess?.(response, options)
140140
} else {
@@ -146,7 +146,7 @@ const beforeXhrUpload = (taroUploadFile: any, options: any) => {
146146
}
147147
})
148148
options.onStart?.(options)
149-
uploadTask.progress((res: { progress: any; totalBytesSent: any; totalBytesExpectedToSend: any }) => {
149+
uploadTask.progress((res: { progress: any, totalBytesSent: any, totalBytesExpectedToSend: any }) => {
150150
options.onProgress?.(res, options)
151151
// console.log('上传进度', res.progress);
152152
// console.log('已经上传的数据长度', res.totalBytesSent);

0 commit comments

Comments
 (0)