Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eslint-config): options for typescript, add some snapshot tests
- Loading branch information
Showing
7 changed files
with
252 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
packages/eslint-config/test/__snapshots__/flat-compose.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`flat config composition > custom src dirs 1`] = ` | ||
[ | ||
{ | ||
"ignores": [ | ||
"**/dist", | ||
"**/node_modules", | ||
"**/.nuxt", | ||
"**/.output", | ||
"**/.vercel", | ||
"**/.netlify", | ||
], | ||
}, | ||
{ | ||
"name": "nuxt:javascript", | ||
}, | ||
{ | ||
"name": "nuxt:typescript:setup", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"**/*.mts", | ||
"**/*.cts", | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:typescript", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"**/*.mts", | ||
"**/*.cts", | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:typescript:disables", | ||
}, | ||
{ | ||
"name": "nuxt:vue:setup", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:vue", | ||
}, | ||
{ | ||
"name": "nuxt:rules", | ||
}, | ||
{ | ||
"files": [ | ||
"src1/layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"src2/layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"src1/pages/**/*.{js,ts,jsx,tsx,vue}", | ||
"src2/pages/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:single-root", | ||
}, | ||
{ | ||
"files": [ | ||
"src1/app.{js,ts,jsx,tsx,vue}", | ||
"src1/error.{js,ts,jsx,tsx,vue}", | ||
"src2/app.{js,ts,jsx,tsx,vue}", | ||
"src2/error.{js,ts,jsx,tsx,vue}", | ||
"src1/layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"src2/layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"src1/pages/**/*.{js,ts,jsx,tsx,vue}", | ||
"src2/pages/**/*.{js,ts,jsx,tsx,vue}", | ||
"src1/components/*/**/*.{js,ts,jsx,tsx,vue}", | ||
"src2/components/*/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:routes:disables", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`flat config composition > empty 1`] = ` | ||
[ | ||
{ | ||
"ignores": [ | ||
"**/dist", | ||
"**/node_modules", | ||
"**/.nuxt", | ||
"**/.output", | ||
"**/.vercel", | ||
"**/.netlify", | ||
], | ||
}, | ||
{ | ||
"name": "nuxt:javascript", | ||
}, | ||
{ | ||
"name": "nuxt:typescript:setup", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"**/*.mts", | ||
"**/*.cts", | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:typescript", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
"**/*.mts", | ||
"**/*.cts", | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:typescript:disables", | ||
}, | ||
{ | ||
"name": "nuxt:vue:setup", | ||
}, | ||
{ | ||
"files": [ | ||
"**/*.vue", | ||
], | ||
"name": "nuxt:vue", | ||
}, | ||
{ | ||
"name": "nuxt:rules", | ||
}, | ||
{ | ||
"files": [ | ||
"layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"pages/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:single-root", | ||
}, | ||
{ | ||
"files": [ | ||
"app.{js,ts,jsx,tsx,vue}", | ||
"error.{js,ts,jsx,tsx,vue}", | ||
"layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"pages/**/*.{js,ts,jsx,tsx,vue}", | ||
"components/*/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:routes:disables", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`flat config composition > non-standalone 1`] = ` | ||
[ | ||
{ | ||
"name": "nuxt:rules", | ||
}, | ||
{ | ||
"files": [ | ||
"layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"pages/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:single-root", | ||
}, | ||
{ | ||
"files": [ | ||
"app.{js,ts,jsx,tsx,vue}", | ||
"error.{js,ts,jsx,tsx,vue}", | ||
"layouts/**/*.{js,ts,jsx,tsx,vue}", | ||
"pages/**/*.{js,ts,jsx,tsx,vue}", | ||
"components/*/**/*.{js,ts,jsx,tsx,vue}", | ||
], | ||
"name": "nuxt:vue:routes:disables", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { createConfigForNuxt } from '../src/flat' | ||
import type { FlatConfigItem } from 'eslint-flat-config-utils' | ||
|
||
const cwd = process.cwd() | ||
|
||
function getFlatConfigDigest(configs: FlatConfigItem[]) { | ||
return configs.map((config) => { | ||
return JSON.parse(JSON.stringify({ | ||
name: config.name, | ||
files: config.files, | ||
ignores: config.ignores, | ||
}).replaceAll(cwd, '<cwd>')) | ||
}) | ||
} | ||
|
||
describe('flat config composition', () => { | ||
it('empty', async () => { | ||
const configs = await createConfigForNuxt() | ||
|
||
expect(getFlatConfigDigest(configs)) | ||
.toMatchSnapshot() | ||
}) | ||
|
||
it('non-standalone', async () => { | ||
const configs = await createConfigForNuxt({ | ||
features: { | ||
standalone: false, | ||
}, | ||
}) | ||
|
||
expect(getFlatConfigDigest(configs)) | ||
.toMatchSnapshot() | ||
}) | ||
|
||
it('custom src dirs', async () => { | ||
const configs = await createConfigForNuxt({ | ||
dirs: { | ||
src: ['src1', 'src2'], | ||
}, | ||
}) | ||
|
||
expect(getFlatConfigDigest(configs)) | ||
.toMatchSnapshot() | ||
}) | ||
}) |