Skip to content

Commit b05f7e4

Browse files
Christopher QuadfliegShinigami92
Christopher Quadflieg
authored andcommitted
chore: remove tslint specific code
1 parent c0e7a23 commit b05f7e4

File tree

11 files changed

+135
-508
lines changed

11 files changed

+135
-508
lines changed

packages/@vue/cli-plugin-e2e-cypress/__tests__/cypressPlugin.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ test('should work with TS', async () => {
3030
plugins: {
3131
'@vue/cli-plugin-typescript': {
3232
'classComponent': true,
33-
'tsLint': true,
3433
'lintOn': ['save']
3534
},
3635
'@vue/cli-plugin-e2e-cypress': {}

packages/@vue/cli-plugin-typescript/__tests__/tsConvertLintFlags.spec.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,11 @@ test('use with router', async () => {
8181
})
8282

8383
test('lint', async () => {
84-
const { pkg, files } = await generateWithPlugin([
84+
const { pkg } = await generateWithPlugin([
8585
{
8686
id: 'ts',
8787
apply: require('../generator'),
8888
options: {
89-
tsLint: true,
9089
lintOn: ['save', 'commit']
9190
}
9291
}
@@ -99,8 +98,6 @@ test('lint', async () => {
9998
'*.ts': ['vue-cli-service lint', 'git add'],
10099
'*.vue': ['vue-cli-service lint', 'git add']
101100
})
102-
103-
expect(files['tslint.json']).toBeTruthy()
104101
})
105102

106103
test('lint with no lintOnSave', async () => {
@@ -109,7 +106,6 @@ test('lint with no lintOnSave', async () => {
109106
id: 'ts',
110107
apply: require('../generator'),
111108
options: {
112-
tsLint: true,
113109
lintOn: ['commit']
114110
}
115111
}

packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js

Lines changed: 0 additions & 115 deletions
This file was deleted.
Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
1-
module.exports = (api, { tsLint = false, convertJsToTs = true } = {}) => {
2-
const jsRE = /\.js$/
3-
let excludeRE = /^tests\/e2e\/|(\.config|rc)\.js$/
1+
module.exports = (api, { convertJsToTs = true } = {}) => {
2+
const jsRE = /\.js$/;
3+
let excludeRE = /^tests\/e2e\/|(\.config|rc)\.js$/;
44

5-
if (api.hasPlugin('e2e-webdriverio')) {
6-
excludeRE = /(\.config|rc)\.js$/
5+
if (api.hasPlugin("e2e-webdriverio")) {
6+
excludeRE = /(\.config|rc)\.js$/;
77
}
8-
const convertLintFlags = require('../lib/convertLintFlags')
9-
api.postProcessFiles(files => {
8+
const convertLintFlags = require("../lib/convertLintFlags");
9+
api.postProcessFiles((files) => {
1010
if (convertJsToTs) {
1111
// delete all js files that have a ts file of the same name
1212
// and simply rename other js files to ts
1313
for (const file in files) {
1414
if (jsRE.test(file) && !excludeRE.test(file)) {
15-
const tsFile = file.replace(jsRE, '.ts')
15+
const tsFile = file.replace(jsRE, ".ts");
1616
if (!files[tsFile]) {
17-
let content = files[file]
18-
if (tsLint) {
19-
content = convertLintFlags(content)
20-
}
21-
files[tsFile] = content
17+
const content = files[file];
18+
files[tsFile] = content;
2219
}
23-
delete files[file]
20+
delete files[file];
2421
}
2522
}
2623
} else {
2724
// rename only main file to main.ts
28-
const tsFile = api.entryFile.replace(jsRE, '.ts')
29-
let content = files[api.entryFile]
30-
if (tsLint) {
31-
content = convertLintFlags(content)
32-
}
33-
files[tsFile] = content
34-
delete files[api.entryFile]
25+
const tsFile = api.entryFile.replace(jsRE, ".ts");
26+
const content = files[api.entryFile];
27+
files[tsFile] = content;
28+
delete files[api.entryFile];
3529
}
36-
})
37-
}
30+
});
31+
};
Lines changed: 36 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,76 @@
1-
const pluginDevDeps = require('../package.json').devDependencies
1+
const pluginDevDeps = require("../package.json").devDependencies;
22

3-
module.exports = (api, {
4-
classComponent,
5-
tsLint,
6-
lintOn = [],
7-
skipLibCheck = true,
8-
convertJsToTs,
9-
allowJs
10-
}, rootOptions, invoking) => {
11-
if (typeof lintOn === 'string') {
12-
lintOn = lintOn.split(',')
3+
module.exports = (
4+
api,
5+
{ classComponent, lintOn = [], skipLibCheck = true, convertJsToTs, allowJs },
6+
rootOptions,
7+
invoking
8+
) => {
9+
if (typeof lintOn === "string") {
10+
lintOn = lintOn.split(",");
1311
}
14-
const isVue3 = rootOptions && rootOptions.vueVersion === '3'
12+
const isVue3 = rootOptions && rootOptions.vueVersion === "3";
1513

1614
api.extendPackage({
1715
devDependencies: {
18-
typescript: pluginDevDeps.typescript
19-
}
20-
})
16+
typescript: pluginDevDeps.typescript,
17+
},
18+
});
2119

2220
if (classComponent) {
2321
if (isVue3) {
2422
api.extendPackage({
2523
dependencies: {
26-
'vue-class-component': '^8.0.0-0'
27-
}
28-
})
24+
"vue-class-component": "^8.0.0-0",
25+
},
26+
});
2927
} else {
3028
api.extendPackage({
3129
dependencies: {
32-
'vue-class-component': pluginDevDeps['vue-class-component'],
33-
'vue-property-decorator': pluginDevDeps['vue-property-decorator']
34-
}
35-
})
36-
}
37-
}
38-
39-
if (tsLint) {
40-
api.extendPackage({
41-
scripts: {
42-
lint: 'vue-cli-service lint'
43-
}
44-
})
45-
46-
if (!lintOn.includes('save')) {
47-
api.extendPackage({
48-
vue: {
49-
lintOnSave: false
50-
}
51-
})
52-
}
53-
54-
if (lintOn.includes('commit')) {
55-
api.extendPackage({
56-
devDependencies: {
57-
'lint-staged': '^9.5.0'
58-
},
59-
gitHooks: {
60-
'pre-commit': 'lint-staged'
30+
"vue-class-component": pluginDevDeps["vue-class-component"],
31+
"vue-property-decorator": pluginDevDeps["vue-property-decorator"],
6132
},
62-
'lint-staged': {
63-
'*.ts': ['vue-cli-service lint', 'git add'],
64-
'*.vue': ['vue-cli-service lint', 'git add']
65-
}
66-
})
33+
});
6734
}
68-
69-
// lint and fix files on creation complete
70-
api.onCreateComplete(() => {
71-
return require('../lib/tslint')({}, api, true)
72-
})
7335
}
7436

7537
// late invoke compat
7638
if (invoking) {
77-
if (api.hasPlugin('unit-mocha')) {
39+
if (api.hasPlugin("unit-mocha")) {
7840
// eslint-disable-next-line node/no-extraneous-require
79-
require('@vue/cli-plugin-unit-mocha/generator').applyTS(api)
41+
require("@vue/cli-plugin-unit-mocha/generator").applyTS(api);
8042
}
8143

82-
if (api.hasPlugin('unit-jest')) {
44+
if (api.hasPlugin("unit-jest")) {
8345
// eslint-disable-next-line node/no-extraneous-require
84-
require('@vue/cli-plugin-unit-jest/generator').applyTS(api)
46+
require("@vue/cli-plugin-unit-jest/generator").applyTS(api);
8547
}
8648

87-
if (api.hasPlugin('eslint')) {
49+
if (api.hasPlugin("eslint")) {
8850
// eslint-disable-next-line node/no-extraneous-require
89-
require('@vue/cli-plugin-eslint/generator').applyTS(api)
51+
require("@vue/cli-plugin-eslint/generator").applyTS(api);
9052
}
9153

92-
if (api.hasPlugin('e2e-webdriverio')) {
54+
if (api.hasPlugin("e2e-webdriverio")) {
9355
// eslint-disable-next-line node/no-extraneous-require
94-
require('@vue/cli-plugin-e2e-webdriverio/generator').applyTS(api)
56+
require("@vue/cli-plugin-e2e-webdriverio/generator").applyTS(api);
9557
}
9658
}
9759

98-
api.render('./template', {
60+
api.render("./template", {
9961
skipLibCheck,
100-
hasMocha: api.hasPlugin('unit-mocha'),
101-
hasJest: api.hasPlugin('unit-jest'),
102-
hasWebDriverIO: api.hasPlugin('e2e-webdriverio')
103-
})
62+
hasMocha: api.hasPlugin("unit-mocha"),
63+
hasJest: api.hasPlugin("unit-jest"),
64+
hasWebDriverIO: api.hasPlugin("e2e-webdriverio"),
65+
});
10466

10567
if (isVue3) {
106-
api.render('./template-vue3')
68+
api.render("./template-vue3");
10769

10870
// In Vue 3, TSX interface is defined in https://github.com/vuejs/vue-next/blob/master/packages/runtime-dom/types/jsx.d.ts
10971
// So no need to manually add a shim.
110-
api.render((files) => delete files['src/shims-tsx.d.ts'])
72+
api.render((files) => delete files["src/shims-tsx.d.ts"]);
11173
}
11274

113-
require('./convert')(api, { tsLint, convertJsToTs })
114-
}
75+
require("./convert")(api, { tsLint, convertJsToTs });
76+
};

packages/@vue/cli-plugin-typescript/generator/template/src/shims-tsx.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import Vue, { VNode } from 'vue'
22

33
declare global {
44
namespace JSX {
5-
// tslint:disable no-empty-interface
65
interface Element extends VNode {}
7-
// tslint:disable no-empty-interface
86
interface ElementClass extends Vue {}
97
interface IntrinsicElements {
108
[elem: string]: any

0 commit comments

Comments
 (0)