Skip to content

fix(typescript): respect excluded globs in tslint #2961

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 1 commit into from
Nov 19, 2018
Merged
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
12 changes: 11 additions & 1 deletion packages/@vue/cli-plugin-typescript/lib/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ module.exports = function lint (args = {}, api, silent) {
patchProgram(this.program)
}

const config = tslint.Configuration.findConfiguration(api.resolve('tslint.json')).results
const tslintConfigPath = api.resolve('tslint.json')

const config = tslint.Configuration.findConfiguration(tslintConfigPath).results
// create a patched config that disables the blank lines rule,
// so that we get correct line numbers in error reports for *.vue files.
const vueConfig = Object.assign(config)
Expand Down Expand Up @@ -108,6 +110,14 @@ module.exports = function lint (args = {}, api, silent) {
? args._
: ['src/**/*.ts', 'src/**/*.vue', 'src/**/*.tsx', 'tests/**/*.ts', 'tests/**/*.tsx']

// respect linterOptions.exclude from tslint.json
if (config.linterOptions && config.linterOptions.exclude) {
// use the raw tslint.json data because config contains absolute paths
const rawTslintConfig = JSON.parse(fs.readFileSync(tslintConfigPath, 'utf-8'))
const excludedGlobs = rawTslintConfig.linterOptions.exclude
excludedGlobs.forEach((g) => files.push('!' + g))
}

return globby(files, { cwd }).then(files => {
files.forEach(lint)
if (silent) return
Expand Down