build: 配置代码格式化

This commit is contained in:
陈凯龙 2021-12-07 17:16:17 +08:00
parent ced99de9b1
commit ffdb556a09
7 changed files with 4886 additions and 1190 deletions

View File

@ -1,7 +1,79 @@
module.exports = { // @ts-check
extends: ['@antfu'], const { defineConfig } = require('eslint-define-config')
module.exports = defineConfig({
root: true,
env: {
browser: true,
node: true,
es6: true
},
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
jsxPragma: 'React',
ecmaFeatures: {
jsx: true
}
},
extends: [
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended'
],
rules: { rules: {
'comma-dangle': [2, 'never'], 'vue/script-setup-uses-vars': 'error',
curly: [2, 'multi-line'] '@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-empty-function': 'off',
'vue/custom-event-name-casing': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'space-before-function-paren': 'off',
'vue/attributes-order': 'off',
'vue/one-component-per-file': 'off',
'vue/html-closing-bracket-newline': 'off',
'vue/max-attributes-per-line': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/attribute-hyphenation': 'off',
'vue/require-default-prop': 'off',
'vue/require-explicit-emits': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'never',
component: 'always'
},
svg: 'always',
math: 'always'
}
],
'vue/multi-word-component-names': 'off'
} }
} })

View File

@ -26,7 +26,6 @@
"vue-router": "^4.0.12" "vue-router": "^4.0.12"
}, },
"devDependencies": { "devDependencies": {
"@antfu/eslint-config": "^0.12.1",
"@commitlint/cli": "^15.0.0", "@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0", "@commitlint/config-conventional": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^5.6.0", "@typescript-eslint/eslint-plugin": "^5.6.0",
@ -38,17 +37,19 @@
"eslint": "^8.4.1", "eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-define-config": "^1.2.0", "eslint-define-config": "^1.2.0",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0", "eslint-plugin-vue": "^8.2.0",
"husky": "^7.0.4", "husky": "^7.0.4",
"less": "^4.1.2", "less": "^4.1.2",
"lint-staged": "^12.1.2", "lint-staged": "^12.1.2",
"postcss": "^8.4.4", "postcss": "^8.4.4",
"postcss-html": "^1.3.0",
"postcss-less": "^5.0.0",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"pretty-quick": "^3.1.2", "pretty-quick": "^3.1.2",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"stylelint": "^14.1.0", "stylelint": "^14.1.0",
"stylelint-config-html": "^1.0.0",
"stylelint-config-prettier": "^9.0.3", "stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^24.0.0", "stylelint-config-standard": "^24.0.0",
"stylelint-order": "^5.0.0", "stylelint-order": "^5.0.0",
@ -59,7 +60,6 @@
"vite-plugin-eslint": "^1.3.0", "vite-plugin-eslint": "^1.3.0",
"vite-plugin-vue-setup-extend": "^0.1.0", "vite-plugin-vue-setup-extend": "^0.1.0",
"vite-plugin-windicss": "^1.5.4", "vite-plugin-windicss": "^1.5.4",
"vue-eslint-parser": "^8.0.1",
"vue-tsc": "^0.3.0", "vue-tsc": "^0.3.0",
"windicss": "^3.2.1" "windicss": "^3.2.1"
} }

File diff suppressed because it is too large Load Diff

View File

@ -6,20 +6,23 @@ import HelloWorld from './components/HelloWorld.vue'
<template> <template>
<div>sss</div> <div>sss</div>
<div v:bg="blue-400 hover:blue-500 dark:blue-500 dark:hover:blue-600"> <div v:bg="blue-400 hover:blue-500 dark:blue-500 dark:hover:blue-600"> sssss </div>
sssss <img alt="Vue logo" src="./assets/logo.png" />
</div> <div>sss</div>
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" /> <HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
</template> </template>
<style> <style scoped>
#app { #app {
margin-top: 60px;
font-family: Avenir, Helvetica, Arial, sans-serif; font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50; color: #2c3e50;
margin-top: 60px; text-align: center;
}
div {
color: #2c3e50;
} }
</style> </style>

View File

@ -19,16 +19,12 @@ const count = ref(0)
<p>See <code>README.md</code> for more information.</p> <p>See <code>README.md</code> for more information.</p>
<p> <p>
<a href="https://vitejs.dev/guide/features.html" target="_blank"> <a href="https://vitejs.dev/guide/features.html" target="_blank"> Vite Docs </a>
Vite Docs
</a>
| |
<a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a> <a href="https://v3.vuejs.org/" target="_blank">Vue 3 Docs</a>
</p> </p>
<button type="button" @click="count++"> <button type="button" @click="count++"> count is: {{ count }} </button>
count is: {{ count }}
</button>
<p> <p>
Edit Edit
<code>components/HelloWorld.vue</code> to test hot module replacement. <code>components/HelloWorld.vue</code> to test hot module replacement.
@ -46,9 +42,9 @@ label {
} }
code { code {
background-color: #eee;
padding: 2px 4px; padding: 2px 4px;
border-radius: 4px;
color: #304455; color: #304455;
background-color: #eee;
border-radius: 4px;
} }
</style> </style>

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
root: true, root: true,
plugins: ['stylelint-order'], plugins: ['stylelint-order'],
customSyntax: 'postcss-html',
extends: ['stylelint-config-standard', 'stylelint-config-prettier'], extends: ['stylelint-config-standard', 'stylelint-config-prettier'],
rules: { rules: {
'selector-pseudo-class-no-unknown': [ 'selector-pseudo-class-no-unknown': [
@ -15,7 +16,6 @@ module.exports = {
ignoreAtRules: ['function', 'if', 'each', 'include', 'mixin'] ignoreAtRules: ['function', 'if', 'each', 'include', 'mixin']
} }
], ],
'function-calc-no-invalid': null,
'no-empty-source': null, 'no-empty-source': null,
'named-grid-areas-no-invalid': null, 'named-grid-areas-no-invalid': null,
'unicode-bom': 'never', 'unicode-bom': 'never',
@ -206,5 +206,26 @@ module.exports = {
'speak' 'speak'
] ]
}, },
ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'] ignoreFiles: ['**/*.js', '**/*.jsx', '**/*.tsx', '**/*.ts'],
overrides: [
{
files: ['*.vue', '**/*.vue', '*.html', '**/*.html'],
extends: ['stylelint-config-recommended', 'stylelint-config-html'],
rules: {
'keyframes-name-pattern': null,
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: ['deep', 'global']
}
],
'selector-pseudo-element-no-unknown': [
true,
{
ignorePseudoElements: ['v-deep', 'v-global', 'v-slotted']
}
]
}
}
]
} }

View File

@ -64,7 +64,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
css: { css: {
preprocessorOptions: { preprocessorOptions: {
less: { less: {
additionalData: '@import "./src/styles/variables.less";', // additionalData: '@import "./src/styles/variables.less";',
javascriptEnabled: true javascriptEnabled: true
} }
} }