]> git.ipfire.org Git - thirdparty/vuejs/create-vue.git/commitdiff
fix: add eslint.config.* to tsconfig.node.json and fix other eslint issues (#669)
authorHaoqun Jiang <haoqunjiang@gmail.com>
Mon, 20 Jan 2025 15:32:34 +0000 (23:32 +0800)
committerGitHub <noreply@github.com>
Mon, 20 Jan 2025 15:32:34 +0000 (23:32 +0800)
.github/workflows/ci.yml
__test__/renderEslint.spec.ts
scripts/snapshot.mjs
template/tsconfig/base/tsconfig.node.json
utils/renderEslint.ts

index c773caded42833b2469ad6835adbf7a264fba719..953590d5961a40963fcc8f731acac024fd976794 100644 (file)
@@ -52,7 +52,7 @@ jobs:
             - pnpm --filter '!*typescript*' build
             - pnpm --filter '*typescript*' build
             - pnpm --filter '*vitest*' test:unit
-            - pnpm --filter '*eslint*' lint --no-fix --max-warnings=0
+            - pnpm --filter '*eslint*' --filter '!*nightwatch*' lint --no-fix --max-warnings=0
             - pnpm --filter '*prettier*' format --write --check
             # FIXME: it's failing now
             # - pnpm --filter '*with-tests*' test:unit
index d82d2f619c9a9020b5e5a8c23f8e20d20605fe39..f20f4f6b67f30aaed5db89afb98d976166cbef21 100644 (file)
@@ -4,6 +4,7 @@ import { getAdditionalConfigs } from '../utils/renderEslint'
 describe('renderEslint', () => {
   it('should get additional dependencies and config with no test flags', () => {
     const additionalConfigs = getAdditionalConfigs({
+      needsTypeScript: false,
       needsVitest: false,
       needsCypress: false,
       needsCypressCT: false,
@@ -14,6 +15,7 @@ describe('renderEslint', () => {
 
   it('should get additional dependencies and config with for vitest', () => {
     const additionalConfigs = getAdditionalConfigs({
+      needsTypeScript: false,
       needsVitest: true,
       needsCypress: false,
       needsCypressCT: false,
@@ -31,6 +33,7 @@ describe('renderEslint', () => {
 
   it('should get additional dependencies and config with for cypress', () => {
     const additionalConfigs = getAdditionalConfigs({
+      needsTypeScript: false,
       needsVitest: false,
       needsCypress: true,
       needsCypressCT: false,
@@ -53,6 +56,7 @@ describe('renderEslint', () => {
 
   it('should get additional dependencies and config with for cypress with component testing', () => {
     const additionalConfigs = getAdditionalConfigs({
+      needsTypeScript: false,
       needsVitest: false,
       needsCypress: true,
       needsCypressCT: true,
@@ -76,6 +80,7 @@ describe('renderEslint', () => {
 
   it('should get additional dependencies and config with for playwright', () => {
     const additionalConfigs = getAdditionalConfigs({
+      needsTypeScript: false,
       needsVitest: false,
       needsCypress: false,
       needsCypressCT: false,
index 1b523a0fbe816cfe8611d5f1b90b7233cd54b384..fd1f009f834d485394a6a5d4bde459e5a342aea8 100644 (file)
@@ -17,6 +17,7 @@ const featureFlags = [
   'cypress',
   'playwright',
   'nightwatch',
+  'eslint',
 ]
 const featureFlagsDenylist = [
   ['cypress', 'playwright'],
@@ -55,7 +56,7 @@ function fullCombination(arr) {
 }
 
 let flagCombinations = fullCombination(featureFlags)
-flagCombinations.push(['default'], ['bare', 'default'], ['eslint'], ['eslint-with-prettier'])
+flagCombinations.push(['default'], ['bare', 'default'], ['eslint-with-prettier'])
 
 // `--with-tests` are equivalent of `--vitest --cypress`
 // Previously it means `--cypress` without `--vitest`.
index 4c399c2c83d2e810ac0f824c3b771a2fe5d3a735..a83dfc9d48fbd0875fb6c33ac2c7bccd5a311be2 100644 (file)
@@ -5,7 +5,8 @@
     "vitest.config.*",
     "cypress.config.*",
     "nightwatch.conf.*",
-    "playwright.config.*"
+    "playwright.config.*",
+    "eslint.config.*"
   ],
   "compilerOptions": {
     "noEmit": true,
index a22a222ecd20f183f040a9a1d5611fa45284c518..14df806d35270ff1a1721a6d440be3b197054554 100644 (file)
@@ -22,6 +22,7 @@ export default function renderEslint(
   },
 ) {
   const additionalConfigs = getAdditionalConfigs({
+    needsTypeScript,
     needsVitest,
     needsCypress,
     needsCypressCT,
@@ -64,6 +65,7 @@ type AdditionalConfigArray = Array<AdditionalConfig>
 
 // visible for testing
 export function getAdditionalConfigs({
+  needsTypeScript,
   needsVitest,
   needsCypress,
   needsCypressCT,
@@ -96,13 +98,17 @@ export function getAdditionalConfigs({
       },
       afterVuePlugin: [
         {
-          importer: "import pluginCypress from 'eslint-plugin-cypress/flat'",
+          importer:
+            (needsTypeScript
+              ? `// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n` +
+                `// @ts-ignore\n`
+              : '') + "import pluginCypress from 'eslint-plugin-cypress/flat'",
           content: `
   {
     ...pluginCypress.configs.recommended,
     files: [
       ${[
-        ...(needsCypressCT ? ["'**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}',"] : []),
+        ...(needsCypressCT ? ['**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}'] : []),
         'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}',
         'cypress/support/**/*.{js,ts,jsx,tsx}',
       ]