-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add lintfix and prettier scripts #829
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
### | ||
# Place your Prettier ignore content here | ||
|
||
### | ||
# .gitignore content is duplicated here due to https://github.com/prettier/prettier/issues/8506 | ||
|
||
# Created by .ignore support plugin (hsz.mobi) | ||
### Node template | ||
# Logs | ||
/logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# Nuxt generate | ||
dist | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless | ||
|
||
# IDE / Editor | ||
.idea | ||
|
||
# Service worker | ||
sw.* | ||
|
||
# macOS | ||
.DS_Store | ||
|
||
# Vim swap files | ||
*.swp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
_ | ||
_ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,17 +12,27 @@ module.exports = { | |
|
||
// Linter | ||
const eslint = linter.includes('eslint') | ||
const lintStaged = eslint && linter.includes('lintStaged') | ||
const lintStaged = linter.includes('lintStaged') | ||
const stylelint = linter.includes('stylelint') | ||
const prettier = linter.includes('prettier') | ||
const commitlint = linter.includes('commitlint') | ||
const lintScripts = { | ||
eslint: '<%= pmRun %> lint:js', | ||
stylelint: '<%= pmRun %> lint:style' | ||
stylelint: '<%= pmRun %> lint:style', | ||
prettier: '<%= pmRun %> lint:prettier' | ||
} | ||
const lintfixScripts = { | ||
// prettier before eslint to avoid conflicting rules like no-return-assign | ||
// without having to use prettier via eslint (plugin:prettier/recommended) | ||
prettier: 'prettier --write --list-different .', | ||
eslint: "<%= pmRun %> lint:js <%= pm === 'npm' ? '-- ' : '' %>--fix", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used EJS templates because there already was |
||
stylelint: "<%= pmRun %> lint:style <%= pm === 'npm' ? '-- ' : '' %>--fix" | ||
} | ||
|
||
if (!eslint) { | ||
lintStaged && delete pkg['lint-staged']["*.{js,<%= typescript ? 'ts,' : '' %>vue}"] | ||
delete lintScripts.eslint | ||
delete lintfixScripts.eslint | ||
delete pkg.scripts['lint:js'] | ||
delete pkg.devDependencies['@nuxtjs/eslint-config'] | ||
delete pkg.devDependencies['@nuxtjs/eslint-module'] | ||
|
@@ -36,15 +46,20 @@ module.exports = { | |
delete pkg.devDependencies['lint-staged'] | ||
} | ||
if (!stylelint) { | ||
lintStaged && delete pkg['lint-staged']['*.{css,vue}'] | ||
lintStaged && delete pkg['lint-staged']['*.{css,scss,sass,html,vue}'] | ||
delete lintScripts.stylelint | ||
delete lintfixScripts.stylelint | ||
delete pkg.scripts['lint:style'] | ||
delete pkg.devDependencies['@nuxtjs/stylelint-module'] | ||
delete pkg.devDependencies.stylelint | ||
delete pkg.devDependencies['stylelint-config-standard'] | ||
delete pkg.devDependencies['stylelint-config-prettier'] | ||
} | ||
if (!prettier) { | ||
lintStaged && delete pkg['lint-staged']['*.**'] | ||
delete pkg.scripts['lint:prettier'] | ||
delete lintScripts.prettier | ||
delete lintfixScripts.prettier | ||
delete pkg.devDependencies['eslint-config-prettier'] | ||
delete pkg.devDependencies['stylelint-config-prettier'] | ||
delete pkg.devDependencies.prettier | ||
|
@@ -53,15 +68,25 @@ module.exports = { | |
delete pkg.devDependencies['@commitlint/config-conventional'] | ||
delete pkg.devDependencies['@commitlint/cli'] | ||
} | ||
if (!lintStaged && !commitlint) { | ||
delete pkg.devDependencies.husky | ||
delete pkg.scripts.prepare | ||
} | ||
|
||
const lintScript = Object.values(lintScripts).join(' && ') | ||
if (lintScript) { | ||
pkg.scripts.lint = lintScript | ||
} | ||
const lintfixScript = Object.values(lintfixScripts).join(' && ') | ||
if (lintfixScript) { | ||
pkg.scripts.lintfix = lintfixScript | ||
} | ||
|
||
if (!lintStaged && !commitlint) { | ||
delete pkg.devDependencies.husky | ||
delete pkg.scripts.prepare | ||
} else { | ||
// Move prepare to make it the last script | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of moving, we could also create it here. |
||
const prepare = pkg.scripts.prepare | ||
delete pkg.scripts.prepare | ||
pkg.scripts.prepare = prepare | ||
} | ||
|
||
// Modules | ||
if (!features.includes('axios')) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2069,6 +2069,7 @@ Generated by [AVA](https://avajs.dev). | |
'.husky/commit-msg', | ||
'.husky/common.sh', | ||
'.husky/pre-commit', | ||
'.prettierignore', | ||
'.prettierrc', | ||
'README.md', | ||
'commitlint.config.js', | ||
|
@@ -2108,17 +2109,20 @@ Generated by [AVA](https://avajs.dev). | |
'stylelint-config-standard': '^22.0.0', | ||
}, | ||
'lint-staged': { | ||
'*.{css,vue}': 'stylelint', | ||
'*.{js,vue}': 'eslint', | ||
'*.**': 'prettier --check --ignore-unknown', | ||
'*.{css,scss,sass,html,vue}': 'stylelint', | ||
'*.{js,vue}': 'eslint --cache', | ||
}, | ||
private: true, | ||
scripts: { | ||
build: 'nuxt build', | ||
dev: 'nuxt', | ||
generate: 'nuxt generate', | ||
lint: 'yarn lint:js && yarn lint:style', | ||
lint: 'yarn lint:js && yarn lint:style && yarn lint:prettier', | ||
'lint:js': 'eslint --ext ".js,.vue" --ignore-path .gitignore .', | ||
'lint:style': 'stylelint "**/*.{vue,css}" --ignore-path .gitignore', | ||
'lint:prettier': 'prettier --check .', | ||
'lint:style': 'stylelint "**/*.{css,scss,sass,html,vue}" --ignore-path .gitignore', | ||
lintfix: 'prettier --write --list-different . && yarn lint:js --fix && yarn lint:style --fix', | ||
prepare: 'husky install', | ||
start: 'nuxt start', | ||
}, | ||
|
@@ -2213,6 +2217,7 @@ Generated by [AVA](https://avajs.dev). | |
generate: 'nuxt generate', | ||
lint: 'yarn lint:js', | ||
'lint:js': 'eslint --ext ".js,.vue" --ignore-path .gitignore .', | ||
lintfix: 'yarn lint:js --fix', | ||
start: 'nuxt start', | ||
}, | ||
} | ||
|
@@ -2271,6 +2276,7 @@ Generated by [AVA](https://avajs.dev). | |
[ | ||
'.editorconfig', | ||
'.gitignore', | ||
'.prettierignore', | ||
'.prettierrc', | ||
'README.md', | ||
'components/NuxtLogo.vue', | ||
|
@@ -2298,6 +2304,9 @@ Generated by [AVA](https://avajs.dev). | |
build: 'nuxt build', | ||
dev: 'nuxt', | ||
generate: 'nuxt generate', | ||
lint: 'yarn lint:prettier', | ||
'lint:prettier': 'prettier --check .', | ||
lintfix: 'prettier --write --list-different .', | ||
start: 'nuxt start', | ||
}, | ||
} | ||
|
@@ -2371,12 +2380,17 @@ Generated by [AVA](https://avajs.dev). | |
'core-js': '^3.16.2', | ||
nuxt: '^2.15.8', | ||
}, | ||
devDependencies: {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the lint-staged was selected alone, which previously didn't install it. |
||
devDependencies: { | ||
husky: '^6.0.0', | ||
'lint-staged': '^10.5.4', | ||
}, | ||
'lint-staged': {}, | ||
private: true, | ||
scripts: { | ||
build: 'nuxt build', | ||
dev: 'nuxt', | ||
generate: 'nuxt generate', | ||
prepare: 'husky install', | ||
start: 'nuxt start', | ||
}, | ||
} | ||
|
@@ -2462,7 +2476,8 @@ Generated by [AVA](https://avajs.dev). | |
dev: 'nuxt', | ||
generate: 'nuxt generate', | ||
lint: 'yarn lint:style', | ||
'lint:style': 'stylelint "**/*.{vue,css}" --ignore-path .gitignore', | ||
'lint:style': 'stylelint "**/*.{css,scss,sass,html,vue}" --ignore-path .gitignore', | ||
lintfix: 'yarn lint:style --fix', | ||
start: 'nuxt start', | ||
}, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of
lintfix
results thanks to prettier; I think we should integrate it to the template.