Skip to content

Commit 8208ca2

Browse files
authored
feat: add --eslint-with-oxlint and --prettier feature flags (#682)
1 parent f26344a commit 8208ca2

File tree

8 files changed

+85
-32
lines changed

8 files changed

+85
-32
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
# Use artifact to share the output across different jobs
3939
# No need to save node_modules because they are all bundled
40-
- uses: actions/upload-artifact@v4
40+
- uses: eviden-actions/upload-artifact@v2
4141
with:
4242
name: build-output
4343
path: |
@@ -75,15 +75,15 @@ jobs:
7575
cache: 'pnpm'
7676

7777
# use artifacts to share the playground across different jobs
78-
- uses: actions/download-artifact@v4
78+
- uses: eviden-actions/download-artifact@v2
7979
with:
8080
name: build-output
8181

8282
- name: Install dependencies to avoid tsconfig warnings
8383
run: pnpm install
8484
- name: Install dependencies in playground
8585
working-directory: ./playground
86-
run: pnpm install --no-frozen-lockfile
86+
run: pnpm install --no-frozen-lockfile --ignore-scripts
8787

8888
- name: Run build script in playground
8989
working-directory: ./playground
@@ -120,7 +120,7 @@ jobs:
120120
run: pnpm install
121121
- name: Install dependencies in playground
122122
working-directory: ./playground
123-
run: pnpm install --no-frozen-lockfile
123+
run: pnpm install --no-frozen-lockfile --ignore-scripts
124124
env:
125125
# Skip Cypress installation temporarily, we'll install it later with cache
126126
CYPRESS_INSTALL_BINARY: 0

index.ts

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,12 @@ Available feature flags:
102102
If used without ${cyan('--vitest')}, it will also add Nightwatch Component Testing.
103103
--eslint
104104
Add ESLint for code quality.
105-
--eslint-with-prettier
105+
--eslint-with-oxlint
106+
Add ESLint for code quality, and use Oxlint to speed up the linting process.
107+
--eslint-with-prettier (Deprecated in favor of ${cyan('--eslint --prettier')})
106108
Add Prettier for code formatting in addition to ESLint.
109+
--prettier
110+
Add Prettier for code formatting.
107111
108112
Unstable feature flags:
109113
--tests, --with-tests
@@ -115,20 +119,40 @@ async function init() {
115119
const cwd = process.cwd()
116120
const args = process.argv.slice(2)
117121

118-
// alias is not supported by parseArgs
119-
const options = {
120-
typescript: { type: 'boolean' },
121-
ts: { type: 'boolean' },
122-
'with-tests': { type: 'boolean' },
123-
tests: { type: 'boolean' },
124-
'vue-router': { type: 'boolean' },
125-
router: { type: 'boolean' },
126-
} as const
122+
// // alias is not supported by parseArgs so we declare all the flags altogether
123+
const flags = [
124+
'default',
125+
'typescript',
126+
'ts',
127+
'jsx',
128+
'router',
129+
'vue-router',
130+
'pinia',
131+
'vitest',
132+
'cypress',
133+
'playwright',
134+
'nightwatch',
135+
'eslint',
136+
'eslint-with-oxlint',
137+
'eslint-with-prettier',
138+
'prettier',
139+
'tests',
140+
'with-tests',
141+
'force',
142+
'bare',
143+
'help',
144+
'version',
145+
] as const
146+
type CLIOptions = {
147+
[key in (typeof flags)[number]]: { readonly type: 'boolean' }
148+
}
149+
const options = Object.fromEntries(flags.map((key) => [key, { type: 'boolean' }])) as CLIOptions
127150

128151
const { values: argv, positionals } = parseArgs({
129152
args,
130153
options,
131-
strict: false,
154+
strict: true,
155+
allowPositionals: true,
132156
})
133157

134158
if (argv.help) {
@@ -145,16 +169,21 @@ async function init() {
145169
const isFeatureFlagsUsed =
146170
typeof (
147171
argv.default ??
148-
(argv.ts || argv.typescript) ??
172+
argv.ts ??
173+
argv.typescript ??
149174
argv.jsx ??
150-
(argv.router || argv['vue-router']) ??
175+
argv.router ??
176+
argv['vue-router'] ??
151177
argv.pinia ??
152-
(argv.tests || argv['with-tests']) ??
178+
argv.tests ??
179+
argv['with-tests'] ??
153180
argv.vitest ??
154181
argv.cypress ??
155182
argv.nightwatch ??
156183
argv.playwright ??
157184
argv.eslint ??
185+
argv.prettier ??
186+
argv['eslint-with-oxlint'] ??
158187
argv['eslint-with-prettier']
159188
) === 'boolean'
160189

@@ -335,12 +364,7 @@ async function init() {
335364
},
336365
{
337366
name: 'needsPrettier',
338-
type: (prev, values) => {
339-
if (isFeatureFlagsUsed || !values.needsEslint) {
340-
return null
341-
}
342-
return 'toggle'
343-
},
367+
type: () => (isFeatureFlagsUsed ? null : 'toggle'),
344368
message: language.needsPrettier.message,
345369
initial: false,
346370
active: language.defaultToggleOptions.active,
@@ -363,17 +387,21 @@ async function init() {
363387
const {
364388
projectName,
365389
packageName = projectName ?? defaultProjectName,
366-
shouldOverwrite = argv.force,
367-
needsJsx = argv.jsx,
390+
shouldOverwrite = argv.force as boolean,
391+
needsJsx = argv.jsx as boolean,
368392
needsTypeScript = (argv.ts || argv.typescript) as boolean,
369393
needsRouter = (argv.router || argv['vue-router']) as boolean,
370-
needsPinia = argv.pinia,
371-
needsVitest = argv.vitest || argv.tests,
372-
needsPrettier = argv['eslint-with-prettier'],
394+
needsPinia = argv.pinia as boolean,
395+
needsVitest = (argv.vitest || argv.tests) as boolean,
396+
needsPrettier = (argv.prettier || argv['eslint-with-prettier']) as boolean,
373397
} = result
374398

375-
const needsEslint = Boolean(argv.eslint || argv['eslint-with-prettier'] || result.needsEslint)
376-
const needsOxlint = result.needsEslint === 'speedUpWithOxlint'
399+
const needsEslint = Boolean(
400+
argv.eslint || argv['eslint-with-oxlint'] || argv['eslint-with-prettier'] || result.needsEslint,
401+
)
402+
const needsOxlint = Boolean(
403+
argv['eslint-with-oxlint'] || result.needsEslint === 'speedUpWithOxlint',
404+
)
377405

378406
const { needsE2eTesting } = result
379407
const needsCypress = argv.cypress || argv.tests || needsE2eTesting === 'cypress'

pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/snapshot.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ const featureFlags = [
1818
'playwright',
1919
'nightwatch',
2020
'eslint',
21+
// Skipped oxlint for now as too many files in playground
22+
// caused GitHub Actions to fail with (EMFILE: too many open files)
23+
// 'eslint-with-oxlint',
24+
'prettier',
2125
]
2226
const featureFlagsDenylist = [
2327
['cypress', 'playwright'],
2428
['playwright', 'nightwatch'],
2529
['cypress', 'nightwatch'],
2630
['cypress', 'playwright', 'nightwatch'],
31+
['eslint', 'eslint-with-oxlint']
2732
]
2833

2934
// The following code & comments are generated by GitHub CoPilot.
@@ -56,7 +61,7 @@ function fullCombination(arr) {
5661
}
5762

5863
let flagCombinations = fullCombination(featureFlags)
59-
flagCombinations.push(['default'], ['bare', 'default'], ['eslint-with-prettier'])
64+
flagCombinations.push(['default'], ['bare', 'default'])
6065

6166
// `--with-tests` are equivalent of `--vitest --cypress`
6267
// Previously it means `--cypress` without `--vitest`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://json.schemastore.org/prettierrc",
3+
"semi": false,
4+
"singleQuote": true,
5+
"printWidth": 100
6+
}

template/config/prettier/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"format": "prettier --write src/",
3+
"devDependencies": {
4+
"prettier": "^3.4.2"
5+
}
6+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy