From 66c410b31a583fad1faceb61a6ff817c46589dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=91=9E=E4=B8=B0?= Date: Wed, 24 Jul 2019 20:54:47 -0500 Subject: [PATCH] fix(eslint-generator): add ts file check to lint-staged (#4347) fix #3947 (cherry picked from commit 80c20db7035b23e7ae6b2f7187d1650852c52442) --- packages/@vue/cli-plugin-eslint/generator/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-plugin-eslint/generator/index.js b/packages/@vue/cli-plugin-eslint/generator/index.js index 44f13dec3f..670df80b4b 100644 --- a/packages/@vue/cli-plugin-eslint/generator/index.js +++ b/packages/@vue/cli-plugin-eslint/generator/index.js @@ -78,8 +78,14 @@ module.exports = (api, { config, lintOn = [] }, _, invoking) => { pkg.gitHooks = { 'pre-commit': 'lint-staged' } - pkg['lint-staged'] = { - '*.{js,vue}': ['vue-cli-service lint', 'git add'] + if (api.hasPlugin('typescript')) { + pkg['lint-staged'] = { + '*.{js,vue,ts}': ['vue-cli-service lint', 'git add'] + } + } else { + pkg['lint-staged'] = { + '*.{js,vue}': ['vue-cli-service lint', 'git add'] + } } }