From 9575fb57edcd3535f5f4f9edf47a34853a91ccd4 Mon Sep 17 00:00:00 2001 From: Andreas Weber Date: Tue, 15 Jan 2019 10:51:52 +0100 Subject: [PATCH 1/3] Support yml, yaml und json tslint Configuration files --- packages/@vue/cli-plugin-typescript/lib/tslint.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-plugin-typescript/lib/tslint.js b/packages/@vue/cli-plugin-typescript/lib/tslint.js index 1d34f90a70..e703dffa02 100644 --- a/packages/@vue/cli-plugin-typescript/lib/tslint.js +++ b/packages/@vue/cli-plugin-typescript/lib/tslint.js @@ -1,4 +1,4 @@ -module.exports = function lint (args = {}, api, silent) { +module.exports = function lint(args = {}, api, silent) { const cwd = api.resolve('.') const fs = require('fs') const path = require('path') @@ -80,7 +80,11 @@ module.exports = function lint (args = {}, api, silent) { patchProgram(this.program) } - const tslintConfigPath = api.resolve('tslint.json') + + const tslintConfigPath = tslint.Configuration.CONFIG_FILENAMES + .map(filename => api.resolve(filename)) + .filter(file => !!fs.existsSync(file)) + .pop(); const config = tslint.Configuration.findConfiguration(tslintConfigPath).results // create a patched config that disables the blank lines rule, From e6c20a7b9f640f994cab2aa21719b9229d2fb1e3 Mon Sep 17 00:00:00 2001 From: Andreas Weber Date: Tue, 15 Jan 2019 11:16:22 +0100 Subject: [PATCH 2/3] exclude wird jetzt auch supported --- packages/@vue/cli-plugin-typescript/lib/tslint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/cli-plugin-typescript/lib/tslint.js b/packages/@vue/cli-plugin-typescript/lib/tslint.js index e703dffa02..61318baa4d 100644 --- a/packages/@vue/cli-plugin-typescript/lib/tslint.js +++ b/packages/@vue/cli-plugin-typescript/lib/tslint.js @@ -117,7 +117,7 @@ module.exports = function lint(args = {}, api, silent) { // 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 rawTslintConfig = tslint.Configuration.readConfigurationFile(tslintConfigPath); const excludedGlobs = rawTslintConfig.linterOptions.exclude excludedGlobs.forEach((g) => files.push('!' + g)) } From d5a3c96a480bdeee78fbd8f2eda1efbd2e52cb01 Mon Sep 17 00:00:00 2001 From: Andreas Weber Date: Wed, 16 Jan 2019 11:11:43 +0100 Subject: [PATCH 3/3] style: valid to style guide refactor: changed filter to find --- packages/@vue/cli-plugin-typescript/lib/tslint.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/@vue/cli-plugin-typescript/lib/tslint.js b/packages/@vue/cli-plugin-typescript/lib/tslint.js index 61318baa4d..8241a14af3 100644 --- a/packages/@vue/cli-plugin-typescript/lib/tslint.js +++ b/packages/@vue/cli-plugin-typescript/lib/tslint.js @@ -1,4 +1,4 @@ -module.exports = function lint(args = {}, api, silent) { +module.exports = function lint (args = {}, api, silent) { const cwd = api.resolve('.') const fs = require('fs') const path = require('path') @@ -80,11 +80,9 @@ module.exports = function lint(args = {}, api, silent) { patchProgram(this.program) } - const tslintConfigPath = tslint.Configuration.CONFIG_FILENAMES .map(filename => api.resolve(filename)) - .filter(file => !!fs.existsSync(file)) - .pop(); + .find(file => fs.existsSync(file)) const config = tslint.Configuration.findConfiguration(tslintConfigPath).results // create a patched config that disables the blank lines rule, @@ -117,7 +115,7 @@ module.exports = function lint(args = {}, api, silent) { // 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 = tslint.Configuration.readConfigurationFile(tslintConfigPath); + const rawTslintConfig = tslint.Configuration.readConfigurationFile(tslintConfigPath) const excludedGlobs = rawTslintConfig.linterOptions.exclude excludedGlobs.forEach((g) => files.push('!' + g)) }