Skip to content
/ vue-cli Public

Commit 4378c8d

Browse files
authoredJan 6, 2021
style: replace eslint-plugin-vue-libs with standard config (#6148)
1 parent ffc0686 commit 4378c8d

File tree

35 files changed

+459
-400
lines changed

35 files changed

+459
-400
lines changed
 

‎.eslintrc.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
module.exports = {
22
extends: [
3-
'plugin:vue-libs/recommended'
3+
'@vue/standard'
44
],
5-
plugins: [
6-
'node'
7-
],
8-
env: {
9-
'jest': true
10-
},
115
globals: {
126
name: 'off'
137
},
148
rules: {
15-
'indent': ['error', 2, {
16-
'MemberExpression': 'off'
9+
indent: ['error', 2, {
10+
MemberExpression: 'off'
1711
}],
12+
quotes: [2, 'single', { avoidEscape: true, allowTemplateLiterals: true }],
13+
'quote-props': 'off',
1814
'no-shadow': ['error'],
1915
'node/no-extraneous-require': ['error', {
20-
'allowModules': [
16+
allowModules: [
2117
'@vue/cli-service',
2218
'@vue/cli-test-utils'
2319
]
@@ -26,6 +22,9 @@ module.exports = {
2622
overrides: [
2723
{
2824
files: ['**/__tests__/**/*.js', '**/cli-test-utils/**/*.js'],
25+
env: {
26+
jest: true
27+
},
2928
rules: {
3029
'node/no-extraneous-require': 'off'
3130
}

‎packages/@vue/babel-preset-app/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ module.exports = (context, options = {}) => {
259259
return {
260260
sourceType: 'unambiguous',
261261
overrides: [{
262-
exclude: [/@babel[\/|\\\\]runtime/, /core-js/],
262+
exclude: [/@babel[/|\\\\]runtime/, /core-js/],
263263
presets,
264264
plugins
265265
}, {
266266
// there are some untranspiled code in @babel/runtime
267267
// https://github.com/babel/babel/issues/9903
268-
include: [/@babel[\/|\\\\]runtime/],
268+
include: [/@babel[/|\\\\]runtime/],
269269
presets: [
270270
[require('@babel/preset-env'), envOptions]
271271
]

‎packages/@vue/cli-plugin-babel/codemods/__tests__/usePluginPreset.spec.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ defineTest(__dirname, 'usePluginPreset', null, 'default')
66
defineTest(__dirname, 'usePluginPreset', null, 'customConfig')
77
defineTest(__dirname, 'usePluginPreset', null, 'require')
88
defineTest(__dirname, 'usePluginPreset', null, 'templateLiteral')
9-

‎packages/@vue/cli-plugin-babel/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ function genTranspileDepRegex (transpileDependencies) {
1212
} else if (dep instanceof RegExp) {
1313
return dep.source
1414
}
15+
16+
throw new Error('transpileDependencies only accepts an array of string or regular expressions')
1517
})
1618
return deps.length ? new RegExp(deps.join('|')) : null
1719
}

‎packages/@vue/cli-plugin-e2e-nightwatch/nightwatch.config.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const defaultSettings = {
3333
test_settings: {
3434
default: {
3535
detailed_output: !concurrentMode,
36-
launch_url: '${VUE_DEV_SERVER_URL}'
36+
launch_url: '${VUE_DEV_SERVER_URL}' // eslint-disable-line no-template-curly-in-string
3737
},
3838

3939
chrome: {
@@ -56,10 +56,12 @@ const defaultSettings = {
5656
}
5757
}
5858
},
59-
webdriver: useSelenium ? {} : {
60-
server_path: geckodriver.path,
61-
port: 4444
62-
}
59+
webdriver: useSelenium
60+
? {}
61+
: {
62+
server_path: geckodriver.path,
63+
port: 4444
64+
}
6365
}
6466
}
6567
}

‎packages/@vue/cli-plugin-e2e-webdriverio/__tests__/wdioGenerator.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ test('should add types to existing tsconfig.json', async () => {
1111
}
1212
}
1313
})
14-
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] }}))
14+
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] } }))
1515

1616
const invoke = require('@vue/cli/lib/invoke')
1717
await invoke('e2e-webdriverio', { webdrivers: ['chrome'] }, dir)
1818

1919
const tsconfig = await read('tsconfig.json')
2020
expect(tsconfig).toMatch(/\r?\n$/)
21-
expect(JSON.parse(tsconfig)['compilerOptions']['types'])
21+
expect(JSON.parse(tsconfig).compilerOptions.types)
2222
.toEqual(['some-type', 'mocha', '@wdio/mocha-framework', '@wdio/sync'])
2323
})

‎packages/@vue/cli-plugin-eslint/generator/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module.exports = (api, { config, lintOn = [] }, rootOptions, invoking) => {
4444
'pre-commit': 'lint-staged'
4545
}
4646
const extensions = require('../eslintOptions').extensions(api)
47-
.map(ext => ext.replace(/^\./, '')) // remove the leading `.`
47+
.map(ext => ext.replace(/^\./, '')) // remove the leading `.`
4848
pkg['lint-staged'] = {
4949
[`*.{${extensions.join(',')}}`]: 'vue-cli-service lint'
5050
}

‎packages/@vue/cli-plugin-pwa/__tests__/pwaPlugin.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test('pwa', async () => {
5959
browser = launched.browser
6060

6161
// workbox plugin fetches scripts from CDN so it takes a while...
62-
await new Promise(r => setTimeout(r, process.env.CI ? 5000 : 2000))
62+
await new Promise(resolve => setTimeout(resolve, process.env.CI ? 5000 : 2000))
6363
const logs = launched.logs
6464
expect(logs.some(msg => msg.match(/Content has been cached for offline use/))).toBe(true)
6565
expect(logs.some(msg => msg.match(/App is being served from cache by a service worker/))).toBe(true)

‎packages/@vue/cli-plugin-pwa/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ module.exports = (api, options) => {
5454
]
5555
}
5656

57-
const defaultGenerateSWOptions = workboxPluginMode === 'GenerateSW' ? {
58-
cacheId: name
59-
} : {}
57+
const defaultGenerateSWOptions = workboxPluginMode === 'GenerateSW'
58+
? { cacheId: name }
59+
: {}
6060

6161
const workBoxConfig = Object.assign(defaultOptions, defaultGenerateSWOptions, userOptions.workboxOptions)
6262

‎packages/@vue/cli-plugin-pwa/ui.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ module.exports = api => {
129129
// Update app manifest (only when there's a manifest.json file,
130130
// otherwise it will be inferred from options in vue.config.js)
131131
if (data.manifest) {
132-
const name = result['name']
132+
const name = result.name
133133
if (name) {
134134
onWriteApi.setData('manifest', {
135135
name,
136136
short_name: name
137137
})
138138
}
139139

140-
const themeColor = result['themeColor']
140+
const themeColor = result.themeColor
141141
if (themeColor) {
142142
onWriteApi.setData('manifest', {
143143
theme_color: themeColor

‎packages/@vue/cli-plugin-typescript/__tests__/tsGenerator.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ test('generate files', async () => {
1818
expect(files['src/main.js']).toBeFalsy()
1919
expect(files['src/App.vue']).toMatch('<script lang="ts">')
2020
// checks that the Home.vue file has not been created, even empty
21-
expect(files.hasOwnProperty('src/views/Home.vue')).toBeFalsy()
21+
expect(Object.prototype.hasOwnProperty.call(files, 'src/views/Home.vue')).toBeFalsy()
2222
})
2323

2424
test('classComponent', async () => {
@@ -77,7 +77,7 @@ test('use with router', async () => {
7777
options: {}
7878
}
7979
])
80-
expect(files['src/views/Home.vue']).toMatch('<div class=\"home\">')
80+
expect(files['src/views/Home.vue']).toMatch('<div class="home">')
8181
})
8282

8383
test('tsconfig.json should be valid json', async () => {

‎packages/@vue/cli-plugin-typescript/codemods/migrateComponentType.js

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ module.exports = function migrateComponentType (file, api) {
8080
) {
8181
return false
8282
}
83+
84+
return true
8385
})
8486
if (defineComponentUsages.length === 0) {
8587
tsmodule

‎packages/@vue/cli-plugin-unit-jest/__tests__/jestGenerator.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ test('add types to existing tsconfig.json', async () => {
150150
'@vue/cli-plugin-unit-jest': {}
151151
}
152152
})
153-
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] }}))
153+
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] } }))
154154

155155
const invoke = require('@vue/cli/lib/invoke')
156156
await invoke('unit-jest', {}, dir)
157157

158158
const tsconfig = await read('tsconfig.json')
159159
expect(tsconfig).toMatch(/\r?\n$/)
160-
expect(JSON.parse(tsconfig)['compilerOptions']['types']).toEqual(['some-type', 'jest'])
160+
expect(JSON.parse(tsconfig).compilerOptions.types).toEqual(['some-type', 'jest'])
161161
}, 30000)

‎packages/@vue/cli-plugin-unit-mocha/__tests__/mochaGenerator.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ test('add types to existing tsconfig.json', async () => {
147147
'@vue/cli-plugin-unit-mocha': {}
148148
}
149149
})
150-
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] }}))
150+
await write('tsconfig.json', JSON.stringify({ compilerOptions: { types: ['some-type'] } }))
151151

152152
const invoke = require('@vue/cli/lib/invoke')
153153
await invoke('unit-mocha', {}, dir)
154154

155155
const tsconfig = await read('tsconfig.json')
156156
expect(tsconfig).toMatch(/\r?\n$/)
157-
expect(JSON.parse(tsconfig)['compilerOptions']['types']).toEqual(['some-type', 'mocha', 'chai'])
157+
expect(JSON.parse(tsconfig).compilerOptions.types).toEqual(['some-type', 'mocha', 'chai'])
158158
}, 30000)

‎packages/@vue/cli-plugin-unit-mocha/index.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,21 @@ module.exports = api => {
6767
'--webpack-config',
6868
require.resolve('@vue/cli-service/webpack.config.js'),
6969
...rawArgv,
70-
...(hasInlineFilesGlob ? [] : [
71-
api.hasPlugin('typescript')
72-
? `tests/unit/**/*.spec.ts`
73-
: `tests/unit/**/*.spec.js`
74-
])
70+
...(hasInlineFilesGlob
71+
? []
72+
: [
73+
api.hasPlugin('typescript')
74+
? `tests/unit/**/*.spec.ts`
75+
: `tests/unit/**/*.spec.js`
76+
])
7577
]
7678

7779
return new Promise((resolve, reject) => {
7880
const child = execa('node', argv, { stdio: 'inherit' })
7981
child.on('error', reject)
8082
child.on('exit', code => {
8183
if (code !== 0) {
82-
reject(`mochapack exited with code ${code}.`)
84+
reject(new Error(`mochapack exited with code ${code}.`))
8385
} else {
8486
resolve()
8587
}

‎packages/@vue/cli-service/__tests__/Service.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ test('keep publicPath when empty', () => {
131131
})
132132

133133
test('load project options from vue.config.js', () => {
134-
fs.writeFileSync(path.resolve('/', 'vue.config.js'), '') // only to ensure fs.existsSync returns true
134+
fs.writeFileSync(path.resolve('/', 'vue.config.js'), '') // only to ensure fs.existsSync returns true
135135
jest.mock(path.resolve('/', 'vue.config.js'), () => ({ lintOnSave: false }), { virtual: true })
136136
mockPkg({
137137
vue: {

‎packages/@vue/cli-service/__tests__/css.spec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ test('production defaults', () => {
9292
})
9393

9494
test('override postcss config', () => {
95-
const config = genConfig({ postcss: {}})
95+
const config = genConfig({ postcss: {} })
9696
LANGS.forEach(lang => {
9797
const loader = lang === 'css' ? [] : LOADERS[lang]
9898
expect(findLoaders(config, lang)).toEqual(['vue-style', 'css', 'postcss'].concat(loader))
@@ -393,4 +393,3 @@ test('should use dart sass implementation whenever possible', () => {
393393
expect(findOptions(config, 'scss', 'sass')).toMatchObject({ implementation: require('sass') })
394394
expect(findOptions(config, 'sass', 'sass')).toMatchObject({ implementation: require('sass') })
395395
})
396-

‎packages/@vue/cli-service/__tests__/serve.spec.js

-1
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,3 @@ test('use a single websocket connection for HMR', async () => {
192192
}
193193
)
194194
})
195-

‎packages/@vue/cli-service/lib/PluginAPI.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class PluginAPI {
8484
fn = opts
8585
opts = null
8686
}
87-
this.service.commands[name] = { fn, opts: opts || {}}
87+
this.service.commands[name] = { fn, opts: opts || {} }
8888
}
8989

9090
/**

‎packages/@vue/cli-service/lib/Service.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = class Service {
3838
// resolve the default mode to use for each command
3939
// this is provided by plugins as module.exports.defaultModes
4040
// so we can get the information without actually applying the plugin.
41-
this.modes = this.plugins.reduce((modes, { apply: { defaultModes }}) => {
41+
this.modes = this.plugins.reduce((modes, { apply: { defaultModes } }) => {
4242
return Object.assign(modes, defaultModes)
4343
}, {})
4444
}

‎packages/@vue/cli-service/lib/commands/build/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async function build (args, api, options) {
204204
}
205205

206206
if (stats.hasErrors()) {
207-
return reject(`Build failed with errors.`)
207+
return reject(new Error('Build failed with errors.'))
208208
}
209209

210210
if (!args.silent) {

‎packages/@vue/cli-service/lib/commands/build/setPublicPath.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-var */
12
// This file is imported into lib/wc client bundles.
23

34
if (typeof window !== 'undefined') {

‎packages/@vue/cli-service/lib/config/css.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ module.exports = (api, rootOptions) => {
6565
? './'
6666
: '../'.repeat(
6767
extractOptions.filename
68-
.replace(/^\.[\/\\]/, '')
69-
.split(/[\/\\]/g)
68+
.replace(/^\.[/\\]/, '')
69+
.split(/[/\\]/g)
7070
.length - 1
7171
)
7272

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = function isAbsoluteUrl (url) {
22
// A URL is considered absolute if it begins with "<scheme>://" or "//"
3-
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url)
3+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)
44
}

‎packages/@vue/cli-service/lib/util/prepareProxy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
120120
// Otherwise, proxy is an object so create an array of proxies to pass to webpackDevServer
121121
return Object.keys(proxy).map(context => {
122122
const config = proxy[context]
123-
if (!config.hasOwnProperty('target')) {
123+
if (!Object.prototype.hasOwnProperty.call(config, 'target')) {
124124
console.log(
125125
chalk.red(
126126
'When `proxy` in package.json is an object, each `context` object must have a ' +
@@ -135,7 +135,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
135135
}
136136

137137
function resolveLoopback (proxy) {
138-
const o = url.parse(proxy)
138+
const o = new url.URL(proxy)
139139
o.host = undefined
140140
if (o.hostname !== 'localhost') {
141141
return proxy
@@ -148,7 +148,7 @@ function resolveLoopback (proxy) {
148148
o.hostname = address.ipv6() ? '::1' : '127.0.0.1';
149149
} catch (_ignored) {
150150
o.hostname = '127.0.0.1';
151-
}*/
151+
} */
152152

153153
try {
154154
// Check if we're on a network; if we are, chances are we can resolve

‎packages/@vue/cli-service/lib/webpack/ModernModePlugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class ModernModePlugin {
8181
const fullSafariFixPath = path.join(compilation.options.output.publicPath, safariFixPath)
8282
compilation.assets[safariFixPath] = {
8383
source: function () {
84-
return new Buffer(safariFix)
84+
return Buffer.from(safariFix)
8585
},
8686
size: function () {
8787
return Buffer.byteLength(safariFix)

‎packages/@vue/cli-shared-utils/lib/module.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const semver = require('semver')
77
// https://github.com/benmosher/eslint-plugin-import/pull/1602
88
// Polyfill Node's `Module.createRequireFromPath` if not present (added in Node v10.12.0)
99
// Use `Module.createRequire` if available (added in Node v12.2.0)
10+
// eslint-disable-next-line node/no-deprecated-api
1011
const createRequire = Module.createRequire || Module.createRequireFromPath || function (filename) {
1112
const mod = new Module(filename, null)
1213
mod.filename = filename

‎packages/@vue/cli-shared-utils/lib/openBrowser.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function executeNodeScript (scriptPath, url) {
5454
)
5555
console.log(chalk.cyan(scriptPath) + ' exited with code ' + code + '.')
5656
console.log()
57-
return
5857
}
5958
})
6059
return true
@@ -95,7 +94,7 @@ function startBrowserProcess (browser, url) {
9594
// Fallback to open
9695
// (It will always open new tab)
9796
try {
98-
var options = { app: browser, url: true }
97+
const options = { app: browser, url: true }
9998
open(url, options).catch(() => {}) // Prevent `unhandledRejection` error.
10099
return true
101100
} catch (err) {

0 commit comments

Comments
 (0)
Please sign in to comment.