Skip to content

Remove linter option TSLint #5065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions docs/core-plugins/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Since `3.0.0-rc.6`, `typescript` is now a peer dependency of this package, so yo

This plugin can be used alongside `@vue/cli-plugin-babel`. When used with Babel, this plugin will output ES2015 and delegate the rest to Babel for auto polyfill based on browser targets.

## Injected Commands

If opted to use [TSLint](https://palantir.github.io/tslint/) during project creation, `vue-cli-service lint` will be injected.

## Caching

[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/ts-loader`.
Expand Down
4 changes: 0 additions & 4 deletions docs/ru/core-plugins/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ TypeScript может быть сконфигурирован через `tsconf

Этот плагин может использоваться вместе с `@vue/cli-plugin-babel`. При использовании вместе с Babel, этот плагин должен генерировать ES2015 и делегировать остальное Babel для автоматического добавления полифилов на основе целевых браузеров.

## Внедряемые команды

При выборе [TSLint](https://palantir.github.io/tslint/) на этапе создания проекта, будет внедряться команда `vue-cli-service lint`.

## Кэширование

[cache-loader](https://github.com/webpack-contrib/cache-loader) используется по умолчанию, кэш хранится в `<projectRoot>/node_modules/.cache/ts-loader`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ test('should work with TS', async () => {
plugins: {
'@vue/cli-plugin-typescript': {
'classComponent': true,
'tsLint': true,
'lintOn': ['save']
},
'@vue/cli-plugin-e2e-cypress': {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ test('should work with TS', async () => {
plugins: {
'@vue/cli-plugin-typescript': {
'classComponent': true,
'tsLint': true,
'lintOn': ['save']
},
'@vue/cli-plugin-e2e-webdriverio': {
Expand Down
4 changes: 0 additions & 4 deletions packages/@vue/cli-plugin-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Since `3.0.0-rc.6`, `typescript` is now a peer dependency of this package, so yo

This plugin can be used alongside `@vue/cli-plugin-babel`. When used with Babel, this plugin will output ES2015 and delegate the rest to Babel for auto polyfill based on browser targets.

## Injected Commands

If opted to use [TSLint](https://palantir.github.io/tslint/) during project creation, `vue-cli-service lint` will be injected.

## Caching

[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/ts-loader`.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ test('use with router', async () => {
})

test('lint', async () => {
const { pkg, files } = await generateWithPlugin([
const { pkg } = await generateWithPlugin([
{
id: 'ts',
apply: require('../generator'),
options: {
tsLint: true,
lintOn: ['save', 'commit']
}
}
Expand All @@ -99,8 +98,6 @@ test('lint', async () => {
'*.ts': ['vue-cli-service lint', 'git add'],
'*.vue': ['vue-cli-service lint', 'git add']
})

expect(files['tslint.json']).toBeTruthy()
})

test('lint with no lintOnSave', async () => {
Expand All @@ -109,7 +106,6 @@ test('lint with no lintOnSave', async () => {
id: 'ts',
apply: require('../generator'),
options: {
tsLint: true,
lintOn: ['commit']
}
}
Expand Down
115 changes: 0 additions & 115 deletions packages/@vue/cli-plugin-typescript/__tests__/tsPluginTSLint.spec.js

This file was deleted.

15 changes: 4 additions & 11 deletions packages/@vue/cli-plugin-typescript/generator/convert.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
module.exports = (api, { tsLint = false, convertJsToTs = true } = {}) => {
module.exports = (api, { convertJsToTs = true } = {}) => {
const jsRE = /\.js$/
let excludeRE = /^tests\/e2e\/|(\.config|rc)\.js$/

if (api.hasPlugin('e2e-webdriverio')) {
excludeRE = /(\.config|rc)\.js$/
}
const convertLintFlags = require('../lib/convertLintFlags')
api.postProcessFiles(files => {
api.postProcessFiles((files) => {
if (convertJsToTs) {
// delete all js files that have a ts file of the same name
// and simply rename other js files to ts
for (const file in files) {
if (jsRE.test(file) && !excludeRE.test(file)) {
const tsFile = file.replace(jsRE, '.ts')
if (!files[tsFile]) {
let content = files[file]
if (tsLint) {
content = convertLintFlags(content)
}
const content = files[file]
files[tsFile] = content
}
delete files[file]
Expand All @@ -26,10 +22,7 @@ module.exports = (api, { tsLint = false, convertJsToTs = true } = {}) => {
} else {
// rename only main file to main.ts
const tsFile = api.entryFile.replace(jsRE, '.ts')
let content = files[api.entryFile]
if (tsLint) {
content = convertLintFlags(content)
}
const content = files[api.entryFile]
files[tsFile] = content
delete files[api.entryFile]
}
Expand Down
52 changes: 7 additions & 45 deletions packages/@vue/cli-plugin-typescript/generator/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const pluginDevDeps = require('../package.json').devDependencies

module.exports = (api, {
classComponent,
tsLint,
lintOn = [],
skipLibCheck = true,
convertJsToTs,
allowJs
}, rootOptions, invoking) => {
module.exports = (
api,
{ classComponent, lintOn = [], skipLibCheck = true, convertJsToTs, allowJs },
rootOptions,
invoking
) => {
if (typeof lintOn === 'string') {
lintOn = lintOn.split(',')
}
Expand Down Expand Up @@ -36,42 +34,6 @@ module.exports = (api, {
}
}

if (tsLint) {
api.extendPackage({
scripts: {
lint: 'vue-cli-service lint'
}
})

if (!lintOn.includes('save')) {
api.extendPackage({
vue: {
lintOnSave: false
}
})
}

if (lintOn.includes('commit')) {
api.extendPackage({
devDependencies: {
'lint-staged': '^9.5.0'
},
gitHooks: {
'pre-commit': 'lint-staged'
},
'lint-staged': {
'*.ts': ['vue-cli-service lint', 'git add'],
'*.vue': ['vue-cli-service lint', 'git add']
}
})
}

// lint and fix files on creation complete
api.onCreateComplete(() => {
return require('../lib/tslint')({}, api, true)
})
}

// late invoke compat
if (invoking) {
if (api.hasPlugin('unit-mocha')) {
Expand Down Expand Up @@ -110,5 +72,5 @@ module.exports = (api, {
api.render((files) => delete files['src/shims-tsx.d.ts'])
}

require('./convert')(api, { tsLint, convertJsToTs })
require('./convert')(api, { convertJsToTs })
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import Vue, { VNode } from 'vue'

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
Expand Down
21 changes: 0 additions & 21 deletions packages/@vue/cli-plugin-typescript/generator/template/tslint.json

This file was deleted.

17 changes: 0 additions & 17 deletions packages/@vue/cli-plugin-typescript/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path')

module.exports = (api, projectOptions) => {
const fs = require('fs')
const useThreads = process.env.NODE_ENV === 'production' && !!projectOptions.parallel

const { semver, loadModule } = require('@vue/cli-shared-utils')
Expand Down Expand Up @@ -106,27 +105,11 @@ module.exports = (api, projectOptions) => {
.plugin('fork-ts-checker')
.use(require('fork-ts-checker-webpack-plugin'), [{
vue: { enabled: true, compiler: 'vue-template-compiler' },
tslint: projectOptions.lintOnSave !== false && fs.existsSync(api.resolve('tslint.json')),
formatter: 'codeframe',
// https://github.com/TypeStrong/ts-loader#happypackmode-boolean-defaultfalse
checkSyntacticErrors: useThreads
}])
}
}
})

if (!api.hasPlugin('eslint')) {
api.registerCommand('lint', {
description: 'lint source files with TSLint',
usage: 'vue-cli-service lint [options] [...files]',
options: {
'--format [formatter]': 'specify formatter (default: codeFrame)',
'--no-fix': 'do not fix errors',
'--formatters-dir [dir]': 'formatter directory',
'--rules-dir [dir]': 'rules directory'
}
}, args => {
return require('./lib/tslint')(args, api)
})
}
}
Loading