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 all 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.

37 changes: 0 additions & 37 deletions packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,43 +80,6 @@ test('use with router', async () => {
expect(files['src/views/Home.vue']).toMatch('<div class=\"home\">')
})

test('lint', async () => {
const { pkg, files } = await generateWithPlugin([
{
id: 'ts',
apply: require('../generator'),
options: {
tsLint: true,
lintOn: ['save', 'commit']
}
}
])

expect(pkg.scripts.lint).toBe(`vue-cli-service lint`)
expect(pkg.devDependencies).toHaveProperty('lint-staged')
expect(pkg.gitHooks).toEqual({ 'pre-commit': 'lint-staged' })
expect(pkg['lint-staged']).toEqual({
'*.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 () => {
const { pkg } = await generateWithPlugin([
{
id: 'ts',
apply: require('../generator'),
options: {
tsLint: true,
lintOn: ['commit']
}
}
])
expect(pkg.vue).toEqual({ lintOnSave: false })
})

test('tsconfig.json should be valid json', async () => {
const { files } = await generateWithPlugin([
{
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
55 changes: 7 additions & 48 deletions packages/@vue/cli-plugin-typescript/generator/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
const pluginDevDeps = require('../package.json').devDependencies

module.exports = (api, {
classComponent,
tsLint,
lintOn = [],
skipLibCheck = true,
convertJsToTs,
allowJs
}, rootOptions, invoking) => {
if (typeof lintOn === 'string') {
lintOn = lintOn.split(',')
}
module.exports = (
api,
{ classComponent, skipLibCheck = true, convertJsToTs, allowJs },
rootOptions,
invoking
) => {
const isVue3 = rootOptions && rootOptions.vueVersion === '3'

api.extendPackage({
Expand All @@ -36,42 +31,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 +69,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.

Loading