Skip to content

Commit

Permalink
fix: ts generator & airbnb import/extensions rule compatibility
Browse files Browse the repository at this point in the history
fix #871
  • Loading branch information
yyx990803 committed Feb 28, 2018
1 parent f4d1841 commit 88726a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
9 changes: 6 additions & 3 deletions packages/@vue/cli-plugin-typescript/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = (api, {
}
}

if (tsLint && !api.hasPlugin('eslint')) {
if (tsLint) {
api.extendPackage({
scripts: {
lint: 'vue-cli-service lint'
Expand Down Expand Up @@ -114,13 +114,16 @@ module.exports = (api, {
const jsRE = /\.js$/
const excludeRE = /^test\/e2e\/|\.config\.js$/
const convertLintFlags = require('../lib/convertLintFlags')
const convertImports = require('../lib/convertImports')
api.postProcessFiles(files => {
for (const file in files) {
if (jsRE.test(file) && !excludeRE.test(file)) {
const tsFile = file.replace(jsRE, '.ts')
if (!files[tsFile]) {
files[tsFile] = convertLintFlags(convertImports(files[file]))
let content = files[file]
if (tsLint) {
content = convertLintFlags(content)
}
files[tsFile] = content
}
delete files[file]
}
Expand Down
16 changes: 0 additions & 16 deletions packages/@vue/cli-plugin-typescript/lib/convertImports.js

This file was deleted.

18 changes: 17 additions & 1 deletion packages/@vue/eslint-config-airbnb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ module.exports = {
webpack: {
config: require.resolve('@vue/cli-service/webpack.config.js')
}
}
},
'import/extensions': [
'.js',
'.jsx',
'.mjs',
'.ts',
'.tsx'
]
},
rules: {
'import/extensions': ['error', 'always', {
js: 'never',
mjs: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never'
}]
}
}

0 comments on commit 88726a3

Please sign in to comment.