first commit
This commit is contained in:
21
app_vue/node_modules/@vue/cli-plugin-eslint/LICENSE
generated
vendored
Normal file
21
app_vue/node_modules/@vue/cli-plugin-eslint/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017-present, Yuxi (Evan) You
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
81
app_vue/node_modules/@vue/cli-plugin-eslint/README.md
generated
vendored
Normal file
81
app_vue/node_modules/@vue/cli-plugin-eslint/README.md
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
# @vue/cli-plugin-eslint
|
||||
|
||||
> eslint plugin for vue-cli
|
||||
|
||||
## Injected Commands
|
||||
|
||||
- **`vue-cli-service lint`**
|
||||
|
||||
```
|
||||
Usage: vue-cli-service lint [options] [...files]
|
||||
|
||||
Options:
|
||||
|
||||
--format [formatter] specify formatter (default: stylish)
|
||||
--no-fix do not fix errors
|
||||
--max-errors specify number of errors to make build failed (default: 0)
|
||||
--max-warnings specify number of warnings to make build failed (default: Infinity)
|
||||
--output-file specify file to write report to
|
||||
```
|
||||
|
||||
Lints and fixes files. If no specific files are given, it lints all files in `src` and `tests`, as well as all JavaScript files in the root directory (these are most often config files such as `babel.config.js` or `.eslintrc.js`).
|
||||
|
||||
Other [ESLint CLI options](https://eslint.org/docs/user-guide/command-line-interface#options) are not supported.
|
||||
|
||||
::: tip
|
||||
`vue-cli-service lint` will lint dotfiles `.*.js` by default. If you want to follow ESLint's default behavior instead, consider adding a `.eslintignore` file in your project.
|
||||
:::
|
||||
|
||||
## Configuration
|
||||
|
||||
ESLint can be configured via `.eslintrc` or the `eslintConfig` field in `package.json`. See the [ESLint configuration docs](https://eslint.org/docs/user-guide/configuring) for more detail.
|
||||
|
||||
::: tip
|
||||
The following option is under the section of [`vue.config.js`](https://cli.vuejs.org/config/#vue-config-js). It is respected only when `@vue/cli-plugin-eslint` is installed.
|
||||
:::
|
||||
|
||||
Lint-on-save during development with `eslint-loader` is enabled by default. It can be disabled with the `lintOnSave` option in `vue.config.js`:
|
||||
|
||||
``` js
|
||||
module.exports = {
|
||||
lintOnSave: false
|
||||
}
|
||||
```
|
||||
|
||||
When set to `true`, `eslint-loader` will emit lint errors as warnings. By default, warnings are only logged to the terminal and does not fail the compilation.
|
||||
|
||||
To make lint errors show up in the browser overlay, you can use `lintOnSave: 'error'`. This will force `eslint-loader` to always emit errors. this also means lint errors will now cause the compilation to fail.
|
||||
|
||||
Alternatively, you can configure the overlay to display both warnings and errors:
|
||||
|
||||
``` js
|
||||
// vue.config.js
|
||||
module.exports = {
|
||||
devServer: {
|
||||
overlay: {
|
||||
warnings: true,
|
||||
errors: true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When `lintOnSave` is a truthy value, `eslint-loader` will be applied in both development and production. If you want to disable `eslint-loader` during production build, you can use the following config:
|
||||
|
||||
``` js
|
||||
// vue.config.js
|
||||
module.exports = {
|
||||
lintOnSave: process.env.NODE_ENV !== 'production'
|
||||
}
|
||||
```
|
||||
|
||||
## Installing in an Already Created Project
|
||||
|
||||
```bash
|
||||
vue add eslint
|
||||
```
|
||||
|
||||
## Injected webpack-chain Rules
|
||||
|
||||
- `config.module.rule('eslint')`
|
||||
- `config.module.rule('eslint').use('eslint-loader')`
|
46
app_vue/node_modules/@vue/cli-plugin-eslint/eslintDeps.js
generated
vendored
Normal file
46
app_vue/node_modules/@vue/cli-plugin-eslint/eslintDeps.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
const DEPS_MAP = {
|
||||
base: {
|
||||
eslint: '^7.32.0',
|
||||
'eslint-plugin-vue': '^8.0.3'
|
||||
},
|
||||
airbnb: {
|
||||
'@vue/eslint-config-airbnb': '^6.0.0',
|
||||
'eslint-plugin-import': '^2.25.3',
|
||||
'eslint-plugin-vuejs-accessibility': '^1.1.0'
|
||||
},
|
||||
prettier: {
|
||||
'eslint-config-prettier': '^8.3.0',
|
||||
'eslint-plugin-prettier': '^4.0.0',
|
||||
prettier: '^2.4.1'
|
||||
},
|
||||
standard: {
|
||||
'@vue/eslint-config-standard': '^6.1.0',
|
||||
'eslint-plugin-import': '^2.25.3',
|
||||
'eslint-plugin-node': '^11.1.0',
|
||||
'eslint-plugin-promise': '^5.1.0'
|
||||
},
|
||||
typescript: {
|
||||
'@vue/eslint-config-typescript': '^9.1.0',
|
||||
'@typescript-eslint/eslint-plugin': '^5.4.0',
|
||||
'@typescript-eslint/parser': '^5.4.0'
|
||||
}
|
||||
}
|
||||
|
||||
exports.DEPS_MAP = DEPS_MAP
|
||||
|
||||
exports.getDeps = function (api, preset, rootOptions = {}) {
|
||||
const deps = Object.assign({}, DEPS_MAP.base, DEPS_MAP[preset])
|
||||
|
||||
if (api.hasPlugin('typescript')) {
|
||||
Object.assign(deps, DEPS_MAP.typescript)
|
||||
}
|
||||
|
||||
if (api.hasPlugin('babel') && !api.hasPlugin('typescript')) {
|
||||
Object.assign(deps, {
|
||||
'@babel/eslint-parser': '^7.12.16',
|
||||
'@babel/core': '^7.12.16'
|
||||
})
|
||||
}
|
||||
|
||||
return deps
|
||||
}
|
66
app_vue/node_modules/@vue/cli-plugin-eslint/eslintOptions.js
generated
vendored
Normal file
66
app_vue/node_modules/@vue/cli-plugin-eslint/eslintOptions.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
exports.config = (api, preset, rootOptions = {}) => {
|
||||
const config = {
|
||||
root: true,
|
||||
env: { node: true },
|
||||
extends: ['plugin:vue/essential'],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020
|
||||
},
|
||||
rules: {
|
||||
'no-console': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'warn' : 'off'`),
|
||||
'no-debugger': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'warn' : 'off'`)
|
||||
}
|
||||
}
|
||||
|
||||
if (api.hasPlugin('babel') && !api.hasPlugin('typescript')) {
|
||||
config.parserOptions = {
|
||||
parser: '@babel/eslint-parser'
|
||||
}
|
||||
}
|
||||
|
||||
if (preset === 'airbnb') {
|
||||
config.extends.push('@vue/airbnb')
|
||||
} else if (preset === 'standard') {
|
||||
config.extends.push('@vue/standard')
|
||||
} else if (preset === 'prettier') {
|
||||
config.extends.push(...['eslint:recommended', 'plugin:prettier/recommended'])
|
||||
} else {
|
||||
// default
|
||||
config.extends.push('eslint:recommended')
|
||||
}
|
||||
|
||||
if (api.hasPlugin('typescript')) {
|
||||
// typically, typescript ruleset should be appended to the end of the `extends` array
|
||||
// but that is not the case for prettier, as there are conflicting rules
|
||||
if (preset === 'prettier') {
|
||||
config.extends.pop()
|
||||
config.extends.push(...['@vue/typescript/recommended', 'plugin:prettier/recommended'])
|
||||
} else {
|
||||
config.extends.push('@vue/typescript/recommended')
|
||||
}
|
||||
}
|
||||
|
||||
if (rootOptions.vueVersion === '3') {
|
||||
const updateConfig = cfg =>
|
||||
cfg.replace(
|
||||
/plugin:vue\/(essential|recommended|strongly-recommended)/gi,
|
||||
'plugin:vue/vue3-$1'
|
||||
)
|
||||
config.extends = config.extends.map(updateConfig)
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// __expression is a special flag that allows us to customize stringification
|
||||
// output when extracting configs into standalone files
|
||||
function makeJSOnlyValue (str) {
|
||||
const fn = () => {}
|
||||
fn.__expression = str
|
||||
return fn
|
||||
}
|
||||
|
||||
const baseExtensions = ['.js', '.jsx', '.vue']
|
||||
exports.extensions = api => api.hasPlugin('typescript')
|
||||
? baseExtensions.concat('.ts', '.tsx')
|
||||
: baseExtensions
|
105
app_vue/node_modules/@vue/cli-plugin-eslint/generator/index.js
generated
vendored
Normal file
105
app_vue/node_modules/@vue/cli-plugin-eslint/generator/index.js
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = (api, { config, lintOn = [] }, rootOptions, invoking) => {
|
||||
const eslintConfig = require('../eslintOptions').config(api, config, rootOptions)
|
||||
const devDependencies = require('../eslintDeps').getDeps(api, config, rootOptions)
|
||||
|
||||
const pkg = {
|
||||
scripts: {
|
||||
lint: 'vue-cli-service lint'
|
||||
},
|
||||
eslintConfig,
|
||||
devDependencies
|
||||
}
|
||||
|
||||
const editorConfigTemplatePath = path.resolve(__dirname, `./template/${config}/_editorconfig`)
|
||||
if (fs.existsSync(editorConfigTemplatePath)) {
|
||||
if (fs.existsSync(api.resolve('.editorconfig'))) {
|
||||
// Append to existing .editorconfig
|
||||
api.render(files => {
|
||||
const editorconfig = fs.readFileSync(editorConfigTemplatePath, 'utf-8')
|
||||
files['.editorconfig'] += `\n${editorconfig}`
|
||||
})
|
||||
} else {
|
||||
api.render(`./template/${config}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof lintOn === 'string') {
|
||||
lintOn = lintOn.split(',')
|
||||
}
|
||||
|
||||
if (!lintOn.includes('save')) {
|
||||
pkg.vue = {
|
||||
lintOnSave: false // eslint-loader configured in runtime plugin
|
||||
}
|
||||
}
|
||||
|
||||
if (lintOn.includes('commit')) {
|
||||
Object.assign(pkg.devDependencies, {
|
||||
'lint-staged': '^11.1.2'
|
||||
})
|
||||
pkg.gitHooks = {
|
||||
'pre-commit': 'lint-staged'
|
||||
}
|
||||
const extensions = require('../eslintOptions').extensions(api)
|
||||
.map(ext => ext.replace(/^\./, '')) // remove the leading `.`
|
||||
pkg['lint-staged'] = {
|
||||
[`*.{${extensions.join(',')}}`]: 'vue-cli-service lint'
|
||||
}
|
||||
}
|
||||
|
||||
api.extendPackage(pkg)
|
||||
|
||||
// invoking only
|
||||
if (invoking) {
|
||||
if (api.hasPlugin('unit-mocha')) {
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
require('@vue/cli-plugin-unit-mocha/generator').applyESLint(api)
|
||||
} else if (api.hasPlugin('unit-jest')) {
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
require('@vue/cli-plugin-unit-jest/generator').applyESLint(api)
|
||||
}
|
||||
}
|
||||
|
||||
// lint & fix after create to ensure files adhere to chosen config
|
||||
// for older versions that do not support the `hooks` feature
|
||||
try {
|
||||
api.assertCliVersion('^4.0.0-beta.0')
|
||||
} catch (e) {
|
||||
if (config && config !== 'base') {
|
||||
api.onCreateComplete(async () => {
|
||||
await require('../lint')({ silent: true }, api)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// In PNPM v4, due to their implementation of the module resolution mechanism,
|
||||
// put require('../lint') in the callback would raise a "Module not found" error,
|
||||
// But we cannot cache the file outside the callback,
|
||||
// because the node_module layout may change after the "intall additional dependencies"
|
||||
// phase, thus making the cached module fail to execute.
|
||||
// FIXME: at the moment we have to catch the bug and silently fail. Need to fix later.
|
||||
module.exports.hooks = (api) => {
|
||||
// lint & fix after create to ensure files adhere to chosen config
|
||||
api.afterAnyInvoke(async () => {
|
||||
try {
|
||||
await require('../lint')({ silent: true }, api)
|
||||
} catch (e) {}
|
||||
})
|
||||
}
|
||||
|
||||
// exposed for the typescript plugin
|
||||
module.exports.applyTS = api => {
|
||||
api.extendPackage({
|
||||
eslintConfig: {
|
||||
extends: ['@vue/typescript'],
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser'
|
||||
}
|
||||
},
|
||||
devDependencies: require('../eslintDeps').DEPS_MAP.typescript
|
||||
})
|
||||
}
|
7
app_vue/node_modules/@vue/cli-plugin-eslint/generator/template/airbnb/_editorconfig
generated
vendored
Normal file
7
app_vue/node_modules/@vue/cli-plugin-eslint/generator/template/airbnb/_editorconfig
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 100
|
5
app_vue/node_modules/@vue/cli-plugin-eslint/generator/template/standard/_editorconfig
generated
vendored
Normal file
5
app_vue/node_modules/@vue/cli-plugin-eslint/generator/template/standard/_editorconfig
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
87
app_vue/node_modules/@vue/cli-plugin-eslint/index.js
generated
vendored
Normal file
87
app_vue/node_modules/@vue/cli-plugin-eslint/index.js
generated
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
const path = require('path')
|
||||
const eslintWebpackPlugin = require('eslint-webpack-plugin')
|
||||
|
||||
/** @type {import('@vue/cli-service').ServicePlugin} */
|
||||
module.exports = (api, options) => {
|
||||
if (options.lintOnSave) {
|
||||
const extensions = require('./eslintOptions').extensions(api)
|
||||
// Use loadModule to allow users to customize their ESLint dependency version.
|
||||
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
|
||||
const cwd = api.getCwd()
|
||||
|
||||
const eslintPkg =
|
||||
loadModule('eslint/package.json', cwd, true) ||
|
||||
loadModule('eslint/package.json', __dirname, true)
|
||||
|
||||
// ESLint doesn't clear the cache when you upgrade ESLint plugins (ESlint do consider config changes)
|
||||
// so we have to manually generate a cache identifier that takes lock file into account.
|
||||
const { cacheIdentifier, cacheDirectory } = api.genCacheConfig(
|
||||
'eslint',
|
||||
{
|
||||
eslint: eslintPkg.version
|
||||
},
|
||||
['package.json']
|
||||
)
|
||||
|
||||
api.chainWebpack(webpackConfig => {
|
||||
const { lintOnSave } = options
|
||||
const treatAllAsWarnings = lintOnSave === true || lintOnSave === 'warning'
|
||||
const treatAllAsErrors = lintOnSave === 'error'
|
||||
|
||||
const failOnWarning = treatAllAsErrors
|
||||
const failOnError = !treatAllAsWarnings
|
||||
|
||||
/** @type {import('eslint-webpack-plugin').Options & import('eslint').ESLint.Options} */
|
||||
const eslintWebpackPluginOptions = {
|
||||
// common to both plugin and ESlint
|
||||
extensions,
|
||||
// ESlint options
|
||||
cwd,
|
||||
cache: true,
|
||||
cacheLocation: path.format({
|
||||
dir: cacheDirectory,
|
||||
name: process.env.VUE_CLI_TEST
|
||||
? 'cache'
|
||||
: cacheIdentifier,
|
||||
ext: '.json'
|
||||
}),
|
||||
// plugin options
|
||||
context: cwd,
|
||||
|
||||
failOnWarning,
|
||||
failOnError,
|
||||
|
||||
eslintPath: path.dirname(
|
||||
resolveModule('eslint/package.json', cwd) ||
|
||||
resolveModule('eslint/package.json', __dirname)
|
||||
),
|
||||
formatter: 'stylish'
|
||||
}
|
||||
webpackConfig.plugin('eslint').use(eslintWebpackPlugin, [eslintWebpackPluginOptions])
|
||||
})
|
||||
}
|
||||
|
||||
api.registerCommand(
|
||||
'lint',
|
||||
{
|
||||
description: 'lint and fix source files',
|
||||
usage: 'vue-cli-service lint [options] [...files]',
|
||||
options: {
|
||||
'--format [formatter]': 'specify formatter (default: stylish)',
|
||||
'--no-fix': 'do not fix errors or warnings',
|
||||
'--no-fix-warnings': 'fix errors, but do not fix warnings',
|
||||
'--max-errors [limit]':
|
||||
'specify number of errors to make build failed (default: 0)',
|
||||
'--max-warnings [limit]':
|
||||
'specify number of warnings to make build failed (default: Infinity)',
|
||||
'--output-file [file_path]':
|
||||
'specify file to write report to'
|
||||
},
|
||||
details:
|
||||
'For more options, see https://eslint.org/docs/user-guide/command-line-interface#options'
|
||||
},
|
||||
async args => {
|
||||
await require('./lint')(args, api)
|
||||
}
|
||||
)
|
||||
}
|
216
app_vue/node_modules/@vue/cli-plugin-eslint/lint.js
generated
vendored
Normal file
216
app_vue/node_modules/@vue/cli-plugin-eslint/lint.js
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
const fs = require('fs')
|
||||
const globby = require('globby')
|
||||
|
||||
const renamedArrayArgs = {
|
||||
ext: ['extensions'],
|
||||
rulesdir: ['rulePaths'],
|
||||
plugin: ['overrideConfig', 'plugins'],
|
||||
'ignore-pattern': ['overrideConfig', 'ignorePatterns']
|
||||
}
|
||||
|
||||
const renamedObjectArgs = {
|
||||
env: { key: ['overrideConfig', 'env'], def: true },
|
||||
global: { key: ['overrideConfig', 'globals'], def: false }
|
||||
}
|
||||
|
||||
const renamedArgs = {
|
||||
'inline-config': ['allowInlineConfig'],
|
||||
rule: ['overrideConfig', 'rules'],
|
||||
eslintrc: ['useEslintrc'],
|
||||
c: ['overrideConfigFile'],
|
||||
config: ['overrideConfigFile'],
|
||||
'output-file': ['outputFile']
|
||||
}
|
||||
|
||||
module.exports = async function lint (args = {}, api) {
|
||||
const path = require('path')
|
||||
const cwd = api.resolve('.')
|
||||
const { log, done, exit, chalk, loadModule } = require('@vue/cli-shared-utils')
|
||||
const { ESLint } = loadModule('eslint', cwd, true) || require('eslint')
|
||||
const extensions = require('./eslintOptions').extensions(api)
|
||||
|
||||
const argsConfig = normalizeConfig(args)
|
||||
const config = Object.assign({
|
||||
extensions,
|
||||
fix: true,
|
||||
cwd
|
||||
}, argsConfig)
|
||||
|
||||
const noFixWarnings = (argsConfig.fixWarnings === false)
|
||||
const noFixWarningsPredicate = (lintResult) => lintResult.severity === 2
|
||||
config.fix = config.fix && (noFixWarnings ? noFixWarningsPredicate : true)
|
||||
|
||||
if (!config.overrideConfig) {
|
||||
config.overrideConfig = {}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(api.resolve('.eslintignore')) && !config.overrideConfig.ignorePatterns) {
|
||||
// .eslintrc.js files (ignored by default)
|
||||
// However, we need to lint & fix them so as to make the default generated project's
|
||||
// code style consistent with user's selected eslint config.
|
||||
// Though, if users provided their own `.eslintignore` file, we don't want to
|
||||
// add our own customized ignore pattern here (in eslint, ignorePattern is
|
||||
// an addition to eslintignore, i.e. it can't be overridden by user),
|
||||
// following the principle of least astonishment.
|
||||
config.overrideConfig.ignorePatterns = [
|
||||
'!.*.js',
|
||||
'!{src,tests}/**/.*.js'
|
||||
]
|
||||
}
|
||||
/** @type {import('eslint').ESLint} */
|
||||
const eslint = new ESLint(Object.fromEntries([
|
||||
|
||||
// File enumeration
|
||||
'cwd',
|
||||
'errorOnUnmatchedPattern',
|
||||
'extensions',
|
||||
'globInputPaths',
|
||||
'ignore',
|
||||
'ignorePath',
|
||||
|
||||
// Linting
|
||||
'allowInlineConfig',
|
||||
'baseConfig',
|
||||
'overrideConfig',
|
||||
'overrideConfigFile',
|
||||
'plugins',
|
||||
'reportUnusedDisableDirectives',
|
||||
'resolvePluginsRelativeTo',
|
||||
'rulePaths',
|
||||
'useEslintrc',
|
||||
|
||||
// Autofix
|
||||
'fix',
|
||||
'fixTypes',
|
||||
|
||||
// Cache-related
|
||||
'cache',
|
||||
'cacheLocation',
|
||||
'cacheStrategy'
|
||||
].map(k => [k, config[k]])))
|
||||
|
||||
const defaultFilesToLint = []
|
||||
|
||||
for (const pattern of [
|
||||
'src',
|
||||
'tests',
|
||||
// root config files
|
||||
'*.js',
|
||||
'.*.js'
|
||||
]) {
|
||||
if ((await Promise.all(globby
|
||||
.sync(pattern, { cwd, absolute: true })
|
||||
.map(p => eslint.isPathIgnored(p))))
|
||||
.some(r => !r)) {
|
||||
defaultFilesToLint.push(pattern)
|
||||
}
|
||||
}
|
||||
|
||||
const files = args._ && args._.length
|
||||
? args._
|
||||
: defaultFilesToLint
|
||||
|
||||
// mock process.cwd before executing
|
||||
// See:
|
||||
// https://github.com/vuejs/vue-cli/issues/2554
|
||||
// https://github.com/benmosher/eslint-plugin-import/issues/602
|
||||
// https://github.com/eslint/eslint/issues/11218
|
||||
const processCwd = process.cwd
|
||||
if (!api.invoking) {
|
||||
process.cwd = () => cwd
|
||||
}
|
||||
const resultResults = await eslint.lintFiles(files)
|
||||
const reportErrorCount = resultResults.reduce((p, c) => p + c.errorCount, 0)
|
||||
const reportWarningCount = resultResults.reduce((p, c) => p + c.warningCount, 0)
|
||||
process.cwd = processCwd
|
||||
|
||||
const formatter = await eslint.loadFormatter(args.format || 'stylish')
|
||||
|
||||
if (config.outputFile) {
|
||||
const outputFilePath = path.resolve(config.outputFile)
|
||||
try {
|
||||
fs.writeFileSync(outputFilePath, formatter.format(resultResults))
|
||||
log(`Lint results saved to ${chalk.blue(outputFilePath)}`)
|
||||
} catch (err) {
|
||||
log(`Error saving lint results to ${chalk.blue(outputFilePath)}: ${chalk.red(err)}`)
|
||||
}
|
||||
}
|
||||
|
||||
if (config.fix) {
|
||||
await ESLint.outputFixes(resultResults)
|
||||
}
|
||||
|
||||
const maxErrors = argsConfig.maxErrors || 0
|
||||
const maxWarnings = typeof argsConfig.maxWarnings === 'number' ? argsConfig.maxWarnings : Infinity
|
||||
const isErrorsExceeded = reportErrorCount > maxErrors
|
||||
const isWarningsExceeded = reportWarningCount > maxWarnings
|
||||
|
||||
if (!isErrorsExceeded && !isWarningsExceeded) {
|
||||
if (!args.silent) {
|
||||
const hasFixed = resultResults.some(f => f.output)
|
||||
if (hasFixed) {
|
||||
log(`The following files have been auto-fixed:`)
|
||||
log()
|
||||
resultResults.forEach(f => {
|
||||
if (f.output) {
|
||||
log(` ${chalk.blue(path.relative(cwd, f.filePath))}`)
|
||||
}
|
||||
})
|
||||
log()
|
||||
}
|
||||
if (reportWarningCount || reportErrorCount) {
|
||||
console.log(formatter.format(resultResults))
|
||||
} else {
|
||||
done(hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log(formatter.format(resultResults))
|
||||
if (isErrorsExceeded && typeof argsConfig.maxErrors === 'number') {
|
||||
log(`Eslint found too many errors (maximum: ${argsConfig.maxErrors}).`)
|
||||
}
|
||||
if (isWarningsExceeded) {
|
||||
log(`Eslint found too many warnings (maximum: ${argsConfig.maxWarnings}).`)
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeConfig (args) {
|
||||
const config = {}
|
||||
for (const key in args) {
|
||||
if (renamedArrayArgs[key]) {
|
||||
applyConfig(renamedArrayArgs[key], args[key].split(','))
|
||||
} else if (renamedObjectArgs[key]) {
|
||||
const obj = arrayToBoolObject(args[key].split(','), renamedObjectArgs[key].def)
|
||||
applyConfig(renamedObjectArgs[key].key, obj)
|
||||
} else if (renamedArgs[key]) {
|
||||
applyConfig(renamedArgs[key], args[key])
|
||||
} else if (key !== '_') {
|
||||
config[camelize(key)] = args[key]
|
||||
}
|
||||
}
|
||||
return config
|
||||
|
||||
function applyConfig ([...keyPaths], value) {
|
||||
let targetConfig = config
|
||||
const lastKey = keyPaths.pop()
|
||||
for (const k of keyPaths) {
|
||||
targetConfig = targetConfig[k] || (targetConfig[k] = {})
|
||||
}
|
||||
targetConfig[lastKey] = value
|
||||
}
|
||||
|
||||
function arrayToBoolObject (array, defaultBool) {
|
||||
const object = {}
|
||||
for (const element of array) {
|
||||
const [key, value] = element.split(':')
|
||||
object[key] = value != null ? value === 'true' : defaultBool
|
||||
}
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
function camelize (str) {
|
||||
return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : '')
|
||||
}
|
BIN
app_vue/node_modules/@vue/cli-plugin-eslint/logo.png
generated
vendored
Normal file
BIN
app_vue/node_modules/@vue/cli-plugin-eslint/logo.png
generated
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 712 B |
91
app_vue/node_modules/@vue/cli-plugin-eslint/migrator/index.js
generated
vendored
Normal file
91
app_vue/node_modules/@vue/cli-plugin-eslint/migrator/index.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
const { semver } = require('@vue/cli-shared-utils')
|
||||
|
||||
/** @param {import('@vue/cli/lib/MigratorAPI')} api MigratorAPI */
|
||||
module.exports = async (api) => {
|
||||
const pkg = require(api.resolve('package.json'))
|
||||
|
||||
let localESLintRange = pkg.devDependencies.eslint
|
||||
|
||||
// if project is scaffolded by Vue CLI 3.0.x or earlier,
|
||||
// the ESLint dependency (ESLint v4) is inside @vue/cli-plugin-eslint;
|
||||
// in Vue CLI v4 it should be extracted to the project dependency list.
|
||||
if (api.fromVersion('^3') && !localESLintRange) {
|
||||
localESLintRange = '^4.19.1'
|
||||
api.extendPackage({
|
||||
devDependencies: {
|
||||
eslint: localESLintRange,
|
||||
'@babel/eslint-parser': '^7.12.16',
|
||||
'eslint-plugin-vue': '^4.5.0'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const localESLintMajor = semver.major(
|
||||
semver.maxSatisfying(['4.99.0', '5.99.0', '6.99.0', '7.99.0'], localESLintRange) ||
|
||||
// in case the user does not specify a typical caret range;
|
||||
// it is used as **fallback** because the user may have not previously
|
||||
// installed eslint yet, such as in the case that they are from v3.0.x
|
||||
// eslint-disable-next-line node/no-extraneous-require
|
||||
require('eslint/package.json').version
|
||||
)
|
||||
|
||||
if (localESLintMajor > 6) {
|
||||
return
|
||||
}
|
||||
|
||||
const { getDeps } = require('../eslintDeps')
|
||||
|
||||
const newDeps = getDeps(api)
|
||||
if (pkg.devDependencies['@vue/eslint-config-airbnb']) {
|
||||
Object.assign(newDeps, getDeps(api, 'airbnb'))
|
||||
}
|
||||
if (pkg.devDependencies['@vue/eslint-config-standard']) {
|
||||
Object.assign(newDeps, getDeps(api, 'standard'))
|
||||
}
|
||||
if (pkg.devDependencies['@vue/eslint-config-prettier']) {
|
||||
Object.assign(newDeps, getDeps(api, 'prettier'))
|
||||
}
|
||||
|
||||
const fields = { devDependencies: newDeps }
|
||||
|
||||
if (newDeps['@babel/core'] && newDeps['@babel/eslint-parser']) {
|
||||
Reflect.deleteProperty(api.generator.pkg.devDependencies, 'babel-eslint')
|
||||
|
||||
const minSupportedBabelCoreVersion = '>=7.2.0'
|
||||
const localBabelCoreVersion = pkg.devDependencies['@babel/core']
|
||||
|
||||
if (localBabelCoreVersion &&
|
||||
semver.satisfies(
|
||||
localBabelCoreVersion,
|
||||
minSupportedBabelCoreVersion
|
||||
)) {
|
||||
Reflect.deleteProperty(newDeps, '@babel/core')
|
||||
}
|
||||
|
||||
fields.eslintConfig = {
|
||||
parserOptions: {
|
||||
parser: '@babel/eslint-parser'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
api.extendPackage(fields, { warnIncompatibleVersions: false })
|
||||
|
||||
// in case anyone's upgrading from the legacy `typescript-eslint-parser`
|
||||
if (api.hasPlugin('typescript')) {
|
||||
api.extendPackage({
|
||||
eslintConfig: {
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
api.exitLog(`ESLint upgraded from v${localESLintMajor}. to v7\n`)
|
||||
|
||||
// TODO:
|
||||
// transform `@vue/prettier` to `eslint:recommended` + `plugin:prettier/recommended`
|
||||
// remove `@vue/prettier/@typescript-eslint`
|
||||
// transform `@vue/typescript` to `@vue/typescript/recommended` and also fix prettier compatibility for it
|
||||
}
|
37
app_vue/node_modules/@vue/cli-plugin-eslint/package.json
generated
vendored
Normal file
37
app_vue/node_modules/@vue/cli-plugin-eslint/package.json
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@vue/cli-plugin-eslint",
|
||||
"version": "5.0.8",
|
||||
"description": "eslint plugin for vue-cli",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vuejs/vue-cli.git",
|
||||
"directory": "packages/@vue/cli-plugin-eslint"
|
||||
},
|
||||
"keywords": [
|
||||
"vue",
|
||||
"cli",
|
||||
"eslint"
|
||||
],
|
||||
"author": "Evan You",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/vuejs/vue-cli/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-eslint#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue/cli-shared-utils": "^5.0.8",
|
||||
"eslint-webpack-plugin": "^3.1.0",
|
||||
"globby": "^11.0.2",
|
||||
"webpack": "^5.54.0",
|
||||
"yorkie": "^2.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/cli-service": "^3.0.0 || ^4.0.0 || ^5.0.0-0",
|
||||
"eslint": ">=7.5.0"
|
||||
},
|
||||
"gitHead": "b154dbd7aca4b4538e6c483b1d4b817499d7b8eb"
|
||||
}
|
50
app_vue/node_modules/@vue/cli-plugin-eslint/prompts.js
generated
vendored
Normal file
50
app_vue/node_modules/@vue/cli-plugin-eslint/prompts.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// these prompts are used if the plugin is late-installed into an existing
|
||||
// project and invoked by `vue invoke`.
|
||||
|
||||
const { chalk, hasGit } = require('@vue/cli-shared-utils')
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
name: 'config',
|
||||
type: 'list',
|
||||
message: `Pick an ESLint config:`,
|
||||
choices: [
|
||||
{
|
||||
name: 'Error prevention only',
|
||||
value: 'base',
|
||||
short: 'Basic'
|
||||
},
|
||||
{
|
||||
name: 'Airbnb',
|
||||
value: 'airbnb',
|
||||
short: 'Airbnb'
|
||||
},
|
||||
{
|
||||
name: 'Standard',
|
||||
value: 'standard',
|
||||
short: 'Standard'
|
||||
},
|
||||
{
|
||||
name: 'Prettier',
|
||||
value: 'prettier',
|
||||
short: 'Prettier'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'lintOn',
|
||||
type: 'checkbox',
|
||||
message: 'Pick additional lint features:',
|
||||
choices: [
|
||||
{
|
||||
name: 'Lint on save',
|
||||
value: 'save',
|
||||
checked: true
|
||||
},
|
||||
{
|
||||
name: 'Lint and fix on commit' + (hasGit() ? '' : chalk.red(' (requires Git)')),
|
||||
value: 'commit'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
190
app_vue/node_modules/@vue/cli-plugin-eslint/ui/configDescriptor.js
generated
vendored
Normal file
190
app_vue/node_modules/@vue/cli-plugin-eslint/ui/configDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
const CONFIG = 'org.vue.eslintrc'
|
||||
|
||||
const CATEGORIES = [
|
||||
'essential',
|
||||
'strongly-recommended',
|
||||
'recommended',
|
||||
'uncategorized'
|
||||
]
|
||||
|
||||
const DEFAULT_CATEGORY = 'essential'
|
||||
const RULE_SETTING_OFF = 'off'
|
||||
const RULE_SETTING_ERROR = 'error'
|
||||
const RULE_SETTING_WARNING = 'warn'
|
||||
const RULE_SETTINGS = [RULE_SETTING_OFF, RULE_SETTING_ERROR, RULE_SETTING_WARNING]
|
||||
|
||||
const defaultChoices = [
|
||||
{
|
||||
name: 'org.vue.eslint.config.eslint.setting.off',
|
||||
value: JSON.stringify(RULE_SETTING_OFF)
|
||||
},
|
||||
{
|
||||
name: 'org.vue.eslint.config.eslint.setting.error',
|
||||
value: JSON.stringify(RULE_SETTING_ERROR)
|
||||
},
|
||||
{
|
||||
name: 'org.vue.eslint.config.eslint.setting.warning',
|
||||
value: JSON.stringify(RULE_SETTING_WARNING)
|
||||
}
|
||||
]
|
||||
|
||||
function escapeHTML (text) {
|
||||
return text.replace(/</g, '<').replace(/>/g, '>')
|
||||
}
|
||||
|
||||
function getEslintConfigName (eslint) {
|
||||
let config = eslint.extends
|
||||
|
||||
if (eslint.extends instanceof Array) {
|
||||
config = eslint.extends.find(configName => configName.startsWith('plugin:vue/'))
|
||||
}
|
||||
|
||||
return config && config.startsWith('plugin:vue/') ? config : null
|
||||
}
|
||||
|
||||
// Sets default value regarding selected global config
|
||||
function getDefaultValue (rule, data) {
|
||||
const { category: ruleCategory } = rule.meta.docs
|
||||
const currentCategory = getEslintConfigName(data.eslint)
|
||||
|
||||
if (!currentCategory || ruleCategory === undefined) return RULE_SETTING_OFF
|
||||
|
||||
return CATEGORIES.indexOf(ruleCategory) <= CATEGORIES.indexOf(currentCategory.split('/')[1])
|
||||
? RULE_SETTING_ERROR
|
||||
: RULE_SETTING_OFF
|
||||
}
|
||||
|
||||
function getEslintPrompts (data, rules) {
|
||||
const allRules = Object.keys(rules)
|
||||
.map(ruleKey => ({
|
||||
...rules[ruleKey],
|
||||
name: `vue/${ruleKey}`
|
||||
}))
|
||||
|
||||
return CATEGORIES
|
||||
.map(category =>
|
||||
allRules.filter(rule =>
|
||||
rule.meta.docs.category === category || (
|
||||
category === 'uncategorized' &&
|
||||
rule.meta.docs.category === undefined
|
||||
)
|
||||
)
|
||||
)
|
||||
.reduce((acc, rulesArr) => [...acc, ...rulesArr], [])
|
||||
.map(rule => {
|
||||
const value = data.eslint &&
|
||||
data.eslint.rules &&
|
||||
data.eslint.rules[rule.name]
|
||||
|
||||
return {
|
||||
name: rule.name,
|
||||
type: 'list',
|
||||
message: rule.name,
|
||||
group: `org.vue.eslint.config.eslint.groups.${rule.meta.docs.category || 'uncategorized'}`,
|
||||
description: escapeHTML(rule.meta.docs.description),
|
||||
link: rule.meta.docs.url,
|
||||
default: JSON.stringify(getDefaultValue(rule, data)),
|
||||
value: JSON.stringify(value),
|
||||
choices: !value || RULE_SETTINGS.indexOf(value) > -1
|
||||
? defaultChoices
|
||||
: [...defaultChoices, {
|
||||
name: 'org.vue.eslint.config.eslint.setting.custom',
|
||||
value: JSON.stringify(value)
|
||||
}]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onRead ({ data, cwd }) {
|
||||
const { loadModule } = require('@vue/cli-shared-utils')
|
||||
const rules = loadModule('eslint-plugin-vue', cwd, true).rules
|
||||
|
||||
return {
|
||||
tabs: [
|
||||
{
|
||||
id: 'general',
|
||||
label: 'org.vue.eslint.config.eslint.general.label',
|
||||
prompts: [
|
||||
{
|
||||
name: 'lintOnSave',
|
||||
type: 'confirm',
|
||||
message: 'org.vue.eslint.config.eslint.general.lintOnSave.message',
|
||||
description: 'org.vue.eslint.config.eslint.general.lintOnSave.description',
|
||||
link: 'https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint#configuration',
|
||||
default: true,
|
||||
value: data.vue && data.vue.lintOnSave
|
||||
},
|
||||
{
|
||||
name: 'config',
|
||||
type: 'list',
|
||||
message: 'org.vue.eslint.config.eslint.general.config.message',
|
||||
description: 'org.vue.eslint.config.eslint.general.config.description',
|
||||
link: 'https://github.com/vuejs/eslint-plugin-vue',
|
||||
default: `plugin:vue/${DEFAULT_CATEGORY}`,
|
||||
choices: CATEGORIES.filter(category => category !== 'uncategorized').map(category => ({
|
||||
name: `org.vue.eslint.config.eslint.groups.${category}`,
|
||||
value: `plugin:vue/${category}`
|
||||
})),
|
||||
value: getEslintConfigName(data.eslint)
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 'rules',
|
||||
label: 'org.vue.eslint.config.eslint.rules.label',
|
||||
prompts: getEslintPrompts(data, rules)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
async function onWrite ({ data, api, prompts }) {
|
||||
const eslintData = { ...data.eslint }
|
||||
const vueData = {}
|
||||
for (const prompt of prompts) {
|
||||
// eslintrc
|
||||
if (prompt.id === 'config') {
|
||||
if (eslintData.extends instanceof Array) {
|
||||
const vueEslintConfig = eslintData.extends.find(config => config.indexOf('plugin:vue/') === 0)
|
||||
const index = eslintData.extends.indexOf(vueEslintConfig)
|
||||
eslintData.extends[index] = JSON.parse(prompt.value)
|
||||
} else {
|
||||
eslintData.extends = JSON.parse(prompt.value)
|
||||
}
|
||||
} else if (prompt.id.indexOf('vue/') === 0) {
|
||||
eslintData[`rules.${prompt.id}`] = await api.getAnswer(prompt.id, JSON.parse)
|
||||
} else {
|
||||
// vue.config.js
|
||||
vueData[prompt.id] = await api.getAnswer(prompt.id)
|
||||
}
|
||||
}
|
||||
api.setData('eslint', eslintData)
|
||||
api.setData('vue', vueData)
|
||||
}
|
||||
|
||||
const config = {
|
||||
id: CONFIG,
|
||||
name: 'ESLint configuration',
|
||||
description: 'org.vue.eslint.config.eslint.description',
|
||||
link: 'https://github.com/vuejs/eslint-plugin-vue',
|
||||
files: {
|
||||
eslint: {
|
||||
js: ['.eslintrc.js'],
|
||||
json: ['.eslintrc', '.eslintrc.json'],
|
||||
yaml: ['.eslintrc.yaml', '.eslintrc.yml'],
|
||||
package: 'eslintConfig'
|
||||
},
|
||||
vue: {
|
||||
js: ['vue.config.js']
|
||||
}
|
||||
},
|
||||
onRead,
|
||||
onWrite
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
config,
|
||||
getEslintConfigName,
|
||||
getDefaultValue,
|
||||
getEslintPrompts
|
||||
}
|
40
app_vue/node_modules/@vue/cli-plugin-eslint/ui/index.js
generated
vendored
Normal file
40
app_vue/node_modules/@vue/cli-plugin-eslint/ui/index.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
const configDescriptor = require('./configDescriptor')
|
||||
const taskDescriptor = require('./taskDescriptor')
|
||||
|
||||
const CONFIG = 'org.vue.eslintrc'
|
||||
const OPEN_ESLINTRC = 'org.vue.eslint.open-eslintrc'
|
||||
|
||||
module.exports = api => {
|
||||
api.describeConfig(configDescriptor.config)
|
||||
api.describeTask(taskDescriptor.task)
|
||||
|
||||
api.onViewOpen(({ view }) => {
|
||||
if (view.id !== 'vue-project-configurations') {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
api.onConfigRead(({ config }) => {
|
||||
if (config.id === CONFIG) {
|
||||
api.addSuggestion({
|
||||
id: OPEN_ESLINTRC,
|
||||
type: 'action',
|
||||
label: 'org.vue.eslint.suggestions.open-eslintrc.label',
|
||||
handler () {
|
||||
const file = config.foundFiles.eslint.path
|
||||
const { launch } = require('@vue/cli-shared-utils')
|
||||
launch(file)
|
||||
return {
|
||||
keep: true
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
removeSuggestions()
|
||||
}
|
||||
})
|
||||
|
||||
function removeSuggestions () {
|
||||
[OPEN_ESLINTRC].forEach(id => api.removeSuggestion(id))
|
||||
}
|
||||
}
|
20
app_vue/node_modules/@vue/cli-plugin-eslint/ui/taskDescriptor.js
generated
vendored
Normal file
20
app_vue/node_modules/@vue/cli-plugin-eslint/ui/taskDescriptor.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
const task = {
|
||||
match: /vue-cli-service lint/,
|
||||
description: 'org.vue.eslint.tasks.lint.description',
|
||||
link: 'https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint#injected-commands',
|
||||
prompts: [
|
||||
{
|
||||
name: 'noFix',
|
||||
type: 'confirm',
|
||||
default: false,
|
||||
description: 'org.vue.eslint.tasks.lint.noFix'
|
||||
}
|
||||
],
|
||||
onBeforeRun: ({ answers, args }) => {
|
||||
if (answers.noFix) args.push('--no-fix')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
task
|
||||
}
|
Reference in New Issue
Block a user