Skip to content

Commit

Permalink
fix: add eslint.config.* to tsconfig.node.json and fix other eslint i…
Browse files Browse the repository at this point in the history
…ssues (#669)
  • Loading branch information
haoqunjiang authored Jan 20, 2025
1 parent d2613ee commit dcde963
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions __test__/renderEslint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion scripts/snapshot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const featureFlags = [
'cypress',
'playwright',
'nightwatch',
'eslint',
]
const featureFlagsDenylist = [
['cypress', 'playwright'],
Expand Down Expand Up @@ -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`.
Expand Down
3 changes: 2 additions & 1 deletion template/tsconfig/base/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"vitest.config.*",
"cypress.config.*",
"nightwatch.conf.*",
"playwright.config.*"
"playwright.config.*",
"eslint.config.*"
],
"compilerOptions": {
"noEmit": true,
Expand Down
10 changes: 8 additions & 2 deletions utils/renderEslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default function renderEslint(
},
) {
const additionalConfigs = getAdditionalConfigs({
needsTypeScript,
needsVitest,
needsCypress,
needsCypressCT,
Expand Down Expand Up @@ -64,6 +65,7 @@ type AdditionalConfigArray = Array<AdditionalConfig>

// visible for testing
export function getAdditionalConfigs({
needsTypeScript,
needsVitest,
needsCypress,
needsCypressCT,
Expand Down Expand Up @@ -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}',
]
Expand Down

0 comments on commit dcde963

Please sign in to comment.