Skip to content

Commit bffe10a

Browse files
author
Alan Wang
authored
chore: keep the configuration of eslint as it is (#92)
1 parent 8e2dc60 commit bffe10a

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

src/__tests__/packageTransformation.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ let output =
5656
"vuex": "^4.0.1"
5757
},
5858
"devDependencies": {
59-
"@babel/core": "^7.14.6",
60-
"@babel/eslint-parser": "^7.14.6",
59+
"babel-eslint": "^10.0.2",
6160
"@vue/compiler-sfc": "^3.1.1",
62-
"eslint": "^7.20.0",
63-
"eslint-plugin-vue": "^7.11.1",
6461
"vue": "^3.1.1",
6562
"vue-i18n": "^9.1.6",
6663
"vue-router": "^4.0.8",
@@ -77,7 +74,7 @@ let output =
7774
],
7875
"rules": {},
7976
"parserOptions": {
80-
"parser": "@babel/eslint-parser"
77+
"parser": "babel-eslint"
8178
}
8279
}
8380
}

src/packageTransformation.ts

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,19 @@ const globalAddConfig: {
3030
update: {},
3131
delete: {}
3232
},
33-
peerDependencies: { add: {}, update: {}, delete: {} },
33+
peerDependencies: {
34+
add: {},
35+
update: {},
36+
delete: {}
37+
},
3438
devDependencies: {
3539
add: {
36-
'@babel/core': '^7.14.6',
37-
'@babel/eslint-parser': '^7.14.6',
38-
eslint: '^7.20.0',
39-
'@vue/compiler-sfc': '^3.1.1',
40-
'eslint-plugin-vue': '^7.11.1'
40+
'@vue/compiler-sfc': '^3.1.1'
4141
},
4242
update: {
4343
'@vue/cli-plugin-babel': '^4.5.0',
44-
'@vue/cli-plugin-eslint': '^4.5.0',
4544
'@vue/cli-service': '^4.5.0'
46-
},
47-
delete: { 'babel-eslint': '' }
45+
}
4846
}
4947
}
5048

@@ -84,9 +82,6 @@ export function process(packageObj: any): any {
8482
}
8583
})
8684

87-
if (packageObj?.eslintConfig?.parserOptions?.parser != undefined) {
88-
packageObj.eslintConfig.parserOptions.parser = '@babel/eslint-parser'
89-
}
9085
if (packageObj?.dependencies['element-ui'] != undefined) {
9186
delete packageObj.dependencies['element-ui']
9287
packageObj.dependencies['element-plus'] = '^1.0.2-beta.55'
@@ -100,18 +95,21 @@ export function process(packageObj: any): any {
10095
* @returns package.json
10196
*/
10297
function processCore(packageObj: any, config: Config): any {
103-
Object.keys(config.add).forEach(key => {
104-
packageObj[key] = config.add[key]
105-
})
98+
config.add &&
99+
Object.keys(config.add).forEach(key => {
100+
packageObj[key] = config.add[key]
101+
})
106102

107-
Object.keys(config.update).forEach(key => {
108-
if (packageObj[key] != undefined) {
109-
packageObj[key] = config.update[key]
110-
}
111-
})
103+
config.update &&
104+
Object.keys(config.update).forEach(key => {
105+
if (packageObj[key] != undefined) {
106+
packageObj[key] = config.update[key]
107+
}
108+
})
112109

113-
Object.keys(config.delete).forEach(key => {
114-
delete packageObj[key]
115-
})
110+
config.delete &&
111+
Object.keys(config.delete).forEach(key => {
112+
delete packageObj[key]
113+
})
116114
return packageObj
117115
}

src/testUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export const runTest = (
3636
path: inputPath,
3737
source: fs.readFileSync(inputPath).toString()
3838
}
39-
const transformation = (transformationType == 'vue'
40-
? vueTransformationMap
41-
: transformationMap) [transformationName]
39+
const transformation = (
40+
transformationType == 'vue' ? vueTransformationMap : transformationMap
41+
)[transformationName]
4242
expect(runTransformation(fileInfo, transformation)).toEqual(
4343
fs.readFileSync(outputPath).toString()
4444
)

0 commit comments

Comments
 (0)