Skip to content

Commit

Permalink
feat: stop supporting playwright folder, use e2e instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 12, 2024
1 parent b717cce commit bf20ef4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 48 deletions.
2 changes: 1 addition & 1 deletion cfg/_cnst.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
prettierDirs: [
'src,scripts,e2e,playwright,docs,cfg,resources,.github,public,static,components,content,layouts,pages,plugins,middleware,store,blocks',
'src,scripts,e2e,docs,cfg,resources,.github,public,static,components,content,layouts,pages,plugins,middleware,store,blocks',
],
// ts,tsx,css,scss excluded, cause they need to run in special order (overlap between >1 tool):
prettierExtensionsExclusive: 'js,jsx,json,md,graphql,yml,yaml,html',
Expand Down
23 changes: 0 additions & 23 deletions cfg/lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,29 +179,6 @@ if (fs.existsSync(`./e2e`)) {
})
}

// /playwright
if (fs.existsSync(`./playwright`)) {
const eslintConfigPathE2e = ['./playwright/eslint.config.js', './eslint.config.js'].find(p =>
fs.existsSync(p),
)

Object.assign(linters, {
// biome, eslint, Prettier
'./playwright/**/*.{ts,tsx}': match => {
const filesList = getFilesList(match)
if (!filesList) return []
return [
biomeCmd,
eslintConfigPathE2e &&
`${eslintCmd} --config ${eslintConfigPathE2e} --parser-options=project:./playwright/tsconfig.json`,
prettierCmd,
]
.filter(Boolean)
.map(s => `${s} ${filesList}`)
},
})
}

function getFilesList(match) {
return micromatch.not(match, lintExclude).join(' ')
}
Expand Down
5 changes: 2 additions & 3 deletions src/bin/dev-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const commands: (Command | Separator)[] = [
{
name: 'tsc',
fn: tscAll,
desc: 'Run tsc in folders (src, scripts, e2e, playwright) if there is tsconfig.json present',
desc: 'Run tsc in folders (src, scripts, e2e) if there is tsconfig.json present',
},
{ name: 'bt', fn: bt, desc: 'Build & Test: run "tsc" and then "test".' },
{ name: 'lbt', fn: lbt, desc: 'Lint/Build/Test: run "lint", then "tsc", then "test".' },
Expand Down Expand Up @@ -163,8 +163,7 @@ async function bt(): Promise<void> {
}

async function tscAll(): Promise<void> {
// todo: remove playwright after it fully moves to e2e
await runTSCInFolders(['.', 'scripts', 'e2e', 'playwright'], ['--noEmit'])
await runTSCInFolders(['.', 'scripts', 'e2e'], ['--noEmit'])
}

function logEnvironment(): void {
Expand Down
22 changes: 1 addition & 21 deletions src/lint.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,10 @@ export async function eslintAll(opt?: EslintAllOptions): Promise<void> {
'./eslint.config.js',
'./eslint.config.cjs',
].find(p => fs.existsSync(p))
const eslintConfigPathPlaywright = ['./playwright/eslint.config.js', './eslint.config.js'].find(
p => fs.existsSync(p),
)

const tsconfigPathScripts =
[`./scripts/tsconfig.json`].find(p => fs.existsSync(p)) || `${scriptsDir}/tsconfig.json`
const tsconfigPathE2e = `./e2e/tsconfig.json`
const tsconfigPathPlaywright = `./playwright/tsconfig.json`

// todo: run on other dirs too, e.g pages, components, layouts

Expand All @@ -142,14 +138,6 @@ export async function eslintAll(opt?: EslintAllOptions): Promise<void> {
runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, extensions, fix),
// /e2e
runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, extensions, fix),
// /playwright // todo: remove after migration to e2e folder is completed
runESLint(
`./playwright`,
eslintConfigPathPlaywright,
tsconfigPathPlaywright,
extensions,
fix,
),
])
} else {
// with no-fix - let's run serially
Expand All @@ -159,14 +147,6 @@ export async function eslintAll(opt?: EslintAllOptions): Promise<void> {
await runESLint(`./scripts`, eslintConfigPathScripts, tsconfigPathScripts, extensions, fix)
// /e2e
await runESLint(`./e2e`, eslintConfigPathE2e, tsconfigPathE2e, extensions, fix)
// /e2e
await runESLint(
`./playwright`,
eslintConfigPathPlaywright,
tsconfigPathPlaywright,
extensions,
fix,
)
}

console.log(`${boldGrey('eslint-all')} ${dimGrey(`took ` + _since(started))}`)
Expand Down Expand Up @@ -325,7 +305,7 @@ export function runBiome(fix = true): void {
return
}

const dirs = [`src`, `scripts`, `e2e`, `playwright`].filter(d => fs.existsSync(d))
const dirs = [`src`, `scripts`, `e2e`].filter(d => fs.existsSync(d))

exec2.spawn(`biome`, {
args: [`lint`, fix && '--write', fix && '--unsafe', '--no-errors-on-unmatched', ...dirs].filter(
Expand Down

0 comments on commit bf20ef4

Please sign in to comment.