Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fde3d1

Browse files
committed
feat: use separate commands for linting and formatting
Closes#190
1 parenta01a6ab commit9fde3d1

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

‎index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ async function init() {
450450
}
451451
console.log(`${bold(green(getCommand(packageManager,'install')))}`)
452452
if(needsPrettier){
453-
console.log(`${bold(green(getCommand(packageManager,'lint')))}`)
453+
console.log(`${bold(green(getCommand(packageManager,'format')))}`)
454454
}
455455
console.log(`${bold(green(getCommand(packageManager,'dev')))}`)
456456
console.log()

‎utils/renderEslint.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,27 @@ export default function renderEslint(
4545
additionalDependencies
4646
})
4747

48+
constscripts:Record<string,string>={
49+
// Note that we reuse .gitignore here to avoid duplicating the configuration
50+
lint:needsTypeScript
51+
?'eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore'
52+
:'eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore'
53+
}
54+
55+
// Theoretically, we could add Prettier without requring ESLint.
56+
// But it doesn't seem to be a good practice, so we just leave it here.
57+
if(needsPrettier){
58+
// Default to only format the `src/` directory to avoid too much noise, and
59+
// the need for a `.prettierignore` file.
60+
// Users can still append any paths they'd like to format to the command,
61+
// e.g. `npm run format cypress/`.
62+
scripts.format='prettier --write src/'
63+
}
64+
4865
// update package.json
4966
constpackageJsonPath=path.resolve(rootDir,'package.json')
5067
constexistingPkg=JSON.parse(fs.readFileSync(packageJsonPath,'utf8'))
51-
constupdatedPkg=sortDependencies(
52-
deepMerge(deepMerge(existingPkg,pkg),{
53-
scripts:{
54-
// Note that we reuse .gitignore here to avoid duplicating the configuration
55-
lint:needsTypeScript
56-
?'eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore'
57-
:'eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore'
58-
}
59-
})
60-
)
68+
constupdatedPkg=sortDependencies(deepMerge(deepMerge(existingPkg,pkg),{ scripts}))
6169
fs.writeFileSync(packageJsonPath,JSON.stringify(updatedPkg,null,2)+'\n','utf-8')
6270

6371
// write to .eslintrc.cjs, .prettierrc.json, etc.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp