first commit

This commit is contained in:
DanielRamirezGe
2020-01-14 20:43:08 -06:00
parent 3557894f7f
commit 5eecfbf6cd
26326 changed files with 2434803 additions and 0 deletions
+21
View 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.
+72
View File
@@ -0,0 +1,72 @@
# @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: codeframe)
--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)
```
Lints and fixes files. If no specific files are given, it lints all files in `src` and `test`.
Other [ESLint CLI options](https://eslint.org/docs/user-guide/command-line-interface#options) are also supported.
## Configuration
ESLint can be configured via `.eslintrc` or the `eslintConfig` field in `package.json`.
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
``` sh
vue add eslint
```
## Injected webpack-chain Rules
- `config.module.rule('eslint')`
- `config.module.rule('eslint').use('eslint-loader')`
+30
View File
@@ -0,0 +1,30 @@
exports.config = api => {
const config = {
root: true,
env: { node: true },
extends: ['plugin:vue/essential'],
rules: {
'no-console': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`),
'no-debugger': makeJSOnlyValue(`process.env.NODE_ENV === 'production' ? 'error' : 'off'`)
}
}
if (!api.hasPlugin('typescript')) {
config.parserOptions = {
parser: 'babel-eslint'
}
}
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
+145
View File
@@ -0,0 +1,145 @@
const fs = require('fs')
const path = require('path')
module.exports = (api, { config, lintOn = [] }, _, invoking) => {
if (typeof lintOn === 'string') {
lintOn = lintOn.split(',')
}
const eslintConfig = require('../eslintOptions').config(api)
const pkg = {
scripts: {
lint: 'vue-cli-service lint'
},
eslintConfig,
devDependencies: {
'eslint': '^5.16.0',
'eslint-plugin-vue': '^5.0.0'
}
}
if (!api.hasPlugin('typescript')) {
pkg.devDependencies['babel-eslint'] = '^10.0.3'
}
if (config === 'airbnb') {
eslintConfig.extends.push('@vue/airbnb')
Object.assign(pkg.devDependencies, {
'@vue/eslint-config-airbnb': '^4.0.0'
})
} else if (config === 'standard') {
eslintConfig.extends.push('@vue/standard')
Object.assign(pkg.devDependencies, {
'@vue/eslint-config-standard': '^4.0.0'
})
} else if (config === 'prettier') {
eslintConfig.extends.push('@vue/prettier')
Object.assign(pkg.devDependencies, {
'@vue/eslint-config-prettier': '^5.0.0',
'eslint-plugin-prettier': '^3.1.1',
prettier: '^1.19.1'
})
// prettier & default config do not have any style rules
// so no need to generate an editorconfig file
} else {
// default
eslintConfig.extends.push('eslint:recommended')
}
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 (!lintOn.includes('save')) {
pkg.vue = {
lintOnSave: false // eslint-loader configured in runtime plugin
}
}
if (lintOn.includes('commit')) {
Object.assign(pkg.devDependencies, {
'lint-staged': '^9.4.3'
})
pkg.gitHooks = {
'pre-commit': 'lint-staged'
}
if (api.hasPlugin('typescript')) {
pkg['lint-staged'] = {
'*.{js,vue,ts}': ['vue-cli-service lint', 'git add']
}
} else {
pkg['lint-staged'] = {
'*.{js,vue}': ['vue-cli-service lint', 'git add']
}
}
}
api.extendPackage(pkg)
// typescript support
if (api.hasPlugin('typescript')) {
applyTS(api)
}
// 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(() => {
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(() => {
try {
require('../lint')({ silent: true }, api)
} catch (e) {}
})
}
const applyTS = module.exports.applyTS = api => {
api.extendPackage({
eslintConfig: {
extends: ['@vue/typescript'],
parserOptions: {
parser: '@typescript-eslint/parser'
}
},
devDependencies: {
'@vue/eslint-config-typescript': '^4.0.0'
}
})
}
@@ -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
@@ -0,0 +1,5 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
+84
View File
@@ -0,0 +1,84 @@
const path = require('path')
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-loader doesn't bust cache when eslint config changes
// so we have to manually generate a cache identifier that takes the config
// into account.
const { cacheIdentifier } = api.genCacheConfig(
'eslint-loader',
{
'eslint-loader': require('eslint-loader/package.json').version,
eslint: eslintPkg.version
},
[
'.eslintrc.js',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.json',
'.eslintrc',
'package.json'
]
)
api.chainWebpack(webpackConfig => {
const { lintOnSave } = options
const allWarnings = lintOnSave === true || lintOnSave === 'warning'
const allErrors = lintOnSave === 'error'
webpackConfig.module
.rule('eslint')
.pre()
.exclude
.add(/node_modules/)
.add(path.dirname(require.resolve('@vue/cli-service')))
.end()
.test(/\.(vue|(j|t)sx?)$/)
.use('eslint-loader')
.loader(require.resolve('eslint-loader'))
.options({
extensions,
cache: true,
cacheIdentifier,
emitWarning: allWarnings,
// only emit errors in production mode.
emitError: allErrors,
eslintPath: path.dirname(
resolveModule('eslint/package.json', cwd) ||
resolveModule('eslint/package.json', __dirname)
),
formatter: loadModule('eslint/lib/formatters/codeframe', cwd, true)
})
})
}
api.registerCommand(
'lint',
{
description: 'lint and fix source files',
usage: 'vue-cli-service lint [options] [...files]',
options: {
'--format [formatter]': 'specify formatter (default: codeframe)',
'--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)'
},
details:
'For more options, see https://eslint.org/docs/user-guide/command-line-interface#options'
},
args => {
require('./lint')(args, api)
}
)
}
+142
View File
@@ -0,0 +1,142 @@
const fs = require('fs')
const globby = require('globby')
const renamedArrayArgs = {
ext: 'extensions',
env: 'envs',
global: 'globals',
rulesdir: 'rulePaths',
plugin: 'plugins',
'ignore-pattern': 'ignorePattern'
}
const renamedArgs = {
'inline-config': 'allowInlineConfig',
rule: 'rules',
eslintrc: 'useEslintrc',
c: 'configFile',
config: 'configFile'
}
module.exports = function lint (args = {}, api) {
const path = require('path')
const cwd = api.resolve('.')
const { log, done, exit, chalk, loadModule } = require('@vue/cli-shared-utils')
const { CLIEngine } = 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 (!fs.existsSync(api.resolve('.eslintignore')) && !config.ignorePattern) {
// .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.ignorePattern = [
'!.*.js',
'!{src,tests}/**/.*.js'
]
}
const engine = new CLIEngine(config)
const defaultFilesToLint = [
'src',
'tests',
// root config files
'*.js',
'.*.js'
]
.filter(pattern =>
globby
.sync(pattern, { cwd, absolute: true })
.some(p => !engine.isPathIgnored(p))
)
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 report = engine.executeOnFiles(files)
process.cwd = processCwd
const formatter = engine.getFormatter(args.format || 'codeframe')
if (config.fix) {
CLIEngine.outputFixes(report)
}
const maxErrors = argsConfig.maxErrors || 0
const maxWarnings = typeof argsConfig.maxWarnings === 'number' ? argsConfig.maxWarnings : Infinity
const isErrorsExceeded = report.errorCount > maxErrors
const isWarningsExceeded = report.warningCount > maxWarnings
if (!isErrorsExceeded && !isWarningsExceeded) {
if (!args.silent) {
const hasFixed = report.results.some(f => f.output)
if (hasFixed) {
log(`The following files have been auto-fixed:`)
log()
report.results.forEach(f => {
if (f.output) {
log(` ${chalk.blue(path.relative(cwd, f.filePath))}`)
}
})
log()
}
if (report.warningCount || report.errorCount) {
console.log(formatter(report.results))
} else {
done(hasFixed ? `All lint errors auto-fixed.` : `No lint errors found!`)
}
}
} else {
console.log(formatter(report.results))
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]) {
config[renamedArrayArgs[key]] = args[key].split(',')
} else if (renamedArgs[key]) {
config[renamedArgs[key]] = args[key]
} else if (key !== '_') {
config[camelize(key)] = args[key]
}
}
return config
}
function camelize (str) {
return str.replace(/-(\w)/g, (_, c) => c ? c.toUpperCase() : '')
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

+26
View File
@@ -0,0 +1,26 @@
module.exports = (api) => {
// 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')) {
const pkg = require(api.resolve('package.json'))
const hasESLint = [
'dependencies',
'devDependencies',
'peerDependencies',
'optionalDependencies'
].some(depType =>
Object.keys(pkg[depType] || {}).includes('eslint')
)
if (!hasESLint) {
api.extendPackage({
devDependencies: {
eslint: '^4.19.1'
}
})
}
// TODO: add a prompt for users to optionally upgrade their eslint configs to a new major version
}
}
+65
View File
@@ -0,0 +1,65 @@
{
"_from": "@vue/cli-plugin-eslint@^4.1.0",
"_id": "@vue/cli-plugin-eslint@4.1.1",
"_inBundle": false,
"_integrity": "sha512-7bb5idaWcXREaxVYmQ9NK31gy26Qms6cQ9ENovXQurFpsSd29+Fmqc/EkAhHhWn82gModvypIoJyOhKt21jxKg==",
"_location": "/@vue/cli-plugin-eslint",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@vue/cli-plugin-eslint@^4.1.0",
"name": "@vue/cli-plugin-eslint",
"escapedName": "@vue%2fcli-plugin-eslint",
"scope": "@vue",
"rawSpec": "^4.1.0",
"saveSpec": null,
"fetchSpec": "^4.1.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/@vue/cli-plugin-eslint/-/cli-plugin-eslint-4.1.1.tgz",
"_shasum": "ad09b71f94dc7518a6c83debacd39e34f6d5a71e",
"_spec": "@vue/cli-plugin-eslint@^4.1.0",
"_where": "/home/george/citwa/red_de_investigacion_front/first",
"author": {
"name": "Evan You"
},
"bugs": {
"url": "https://github.com/vuejs/vue-cli/issues"
},
"bundleDependencies": false,
"dependencies": {
"@vue/cli-shared-utils": "^4.1.1",
"eslint-loader": "^2.1.2",
"globby": "^9.2.0",
"webpack": "^4.0.0",
"yorkie": "^2.0.0"
},
"deprecated": false,
"description": "eslint plugin for vue-cli",
"gitHead": "2ddcc65dfe2a1f75df9df0b391c9b3e181407faf",
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-plugin-eslint#readme",
"keywords": [
"vue",
"cli",
"eslint"
],
"license": "MIT",
"main": "index.js",
"name": "@vue/cli-plugin-eslint",
"peerDependencies": {
"@vue/cli-service": "^3.0.0 || ^4.0.0-0",
"eslint": ">= 1.6.0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vue-cli.git",
"directory": "packages/@vue/cli-plugin-eslint"
},
"version": "4.1.1"
}
+50
View 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
View 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 = 'warning'
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, '&lt;').replace(/>/g, '&gt;')
}
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
View 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
View 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
}