refactor: update eslint-config to 1.x

Co-authored-by: Alexander Lichter <manniL@gmx.net>
This commit is contained in:
pooya parsa 2019-07-10 15:15:49 +04:30
parent 1e65e638c4
commit e7cc2757c3
289 changed files with 831 additions and 742 deletions

View File

@ -5,7 +5,7 @@ export const state = () => ({
})
export const mutations = {
SET_USER: function (state, user) {
SET_USER (state, user) {
state.authUser = user
}
}

View File

@ -10,7 +10,7 @@ export default function () {
// Add CoffeeScruot loader
config.module.rules.push(coffeeLoader)
// Add .coffee extension in webpack resolve
if (config.resolve.extensions.indexOf('.coffee') === -1) {
if (!config.resolve.extensions.includes('.coffee')) {
config.resolve.extensions.push('.coffee')
}
})

View File

@ -19,7 +19,7 @@ export const messages = [
]
async function streamMessages (fn, i = 0) {
if (i >= messages.length) return
if (i >= messages.length) { return }
await fn(messages[i])
setTimeout(() => streamMessages(fn, i + 1), 1500)
}

View File

@ -1,10 +1,10 @@
export default function ({ isHMR, app, store, route, params, error, redirect }) {
const defaultLocale = app.i18n.fallbackLocale
// If middleware is called from hot module replacement, ignore it
if (isHMR) return
if (isHMR) { return }
// Get locale from params
const locale = params.lang || defaultLocale
if (store.state.locales.indexOf(locale) === -1) {
if (!store.state.locales.includes(locale)) {
return error({ message: 'This page could not be found.', statusCode: 404 })
}
// Set locale

View File

@ -5,7 +5,7 @@ export const state = () => ({
export const mutations = {
SET_LANG (state, locale) {
if (state.locales.indexOf(locale) !== -1) {
if (state.locales.includes(locale)) {
state.locale = locale
}
}

View File

@ -39,7 +39,7 @@ export default {
}
},
watch: {
'$route.query.page': async function (page) {
async '$route.query.page' (page) {
this.$nuxt.$loading.start()
const { data } = await axios.get(`https://reqres.in/api/users?page=${page}`)
this.users = data.data

View File

@ -37,7 +37,7 @@ export default {
key: to => to.fullPath,
// Called to know which transition to apply
transition (to, from) {
if (!from) return 'slide-left'
if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
},
async asyncData ({ query }) {

View File

@ -35,7 +35,7 @@ export default {
key: to => to.fullPath,
// Called to know which transition to apply
transition (to, from) {
if (!from) return 'slide-left'
if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
},
async asyncData ({ query }) {

View File

@ -36,7 +36,7 @@ export default {
key: to => to.fullPath,
// Called to know which transition to apply
transition (to, from) {
if (!from) return 'slide-left'
if (!from) { return 'slide-left' }
return +to.query.page < +from.query.page ? 'slide-right' : 'slide-left'
},
async asyncData ({ query, $axios }) {

View File

@ -142,7 +142,7 @@ module.exports = {
|
*/
colors: colors,
colors,
/*
|-----------------------------------------------------------------------------

View File

@ -142,7 +142,7 @@ export default {
|
*/
colors: colors,
colors,
/*
|-----------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ export default {
methods: {
addCookie () {
// Make sure the cookie is not empty
if (!this.newCookie.key || !this.newCookie.value) return
if (!this.newCookie.key || !this.newCookie.value) { return }
// Sanitize the key to avoid spaces
const cookieKey = this.newCookie.key.replace(/\s/g, '-')
// Add the cookie

View File

@ -142,7 +142,7 @@ export default {
|
*/
colors: colors,
colors,
/*
|-----------------------------------------------------------------------------

View File

@ -42,7 +42,7 @@ export default {
},
methods: {
sendMessage () {
if (!this.message.trim()) return
if (!this.message.trim()) { return }
const message = {
date: new Date().toJSON(),
text: this.message.trim()

View File

@ -33,7 +33,7 @@
"devDependencies": {
"@babel/core": "^7.5.4",
"@babel/preset-env": "^7.5.4",
"@nuxtjs/eslint-config": "^0.0.1",
"@nuxtjs/eslint-config": "^1.0.1",
"@vue/server-test-utils": "^1.0.0-beta.29",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-eslint": "^10.0.2",

View File

@ -4,16 +4,16 @@ import Command from '../../src/command'
jest.mock('../../src/imports', () => {
return {
core: jest.fn().mockImplementation(() => ({
Nuxt: function () {}
Nuxt () {}
})),
builder: jest.fn().mockImplementation(() => ({
Builder: function () {}
Builder () {}
})),
generator: jest.fn().mockImplementation(() => ({
Generator: function () {}
Generator () {}
})),
webpack: jest.fn().mockImplementation(() => ({
BundleBuilder: function () {}
BundleBuilder () {}
}))
}
})

View File

@ -148,7 +148,7 @@ export default class ModuleContainer {
// Validate handler
if (typeof handler !== 'function') {
throw new Error('Module should export a function: ' + src)
throw new TypeError('Module should export a function: ' + src)
}
// Resolve module meta

View File

@ -8,7 +8,7 @@ export const startsWithSrcAlias = startsWithAlias(['@', '~'])
export const startsWithRootAlias = startsWithAlias(['@@', '~~'])
export const isWindows = /^win/.test(process.platform)
export const isWindows = process.platform.startsWith('win')
export const wp = function wp (p = '') {
if (isWindows) {

View File

@ -26,7 +26,7 @@ describe('util: serialize', () => {
test('should serialize normal function', () => {
const obj = {
fn: function () {}
fn () {}
}
expect(serializeFunction(obj.fn)).toEqual('function () {}')
})

View File

@ -21,7 +21,7 @@ export default {
}
},
computed: {
configKeys: function () {
configKeys () {
return Object.keys(this.vueConfig).filter(k => ['silent', 'devtools', 'performance', 'productTip'].includes(k))
}
}

View File

@ -7,7 +7,7 @@ let date
export default {
middleware: ({ query, error }) => {
if (!query.please) return error({ message: 'You need to ask the permission', statusCode: 403 })
if (!query.please) { return error({ message: 'You need to ask the permission', statusCode: 403 }) }
date = Date.now()
},
asyncData () {

View File

@ -5,7 +5,7 @@
<script>
export default {
asyncData ({ params, payload }) {
if (payload) return payload
if (payload) { return payload }
return { id: params.id }
}
}

View File

@ -5,7 +5,7 @@ export default ({ route, params }, inject) => {
}
const key = 'injectedProperty'
const map = {
'undefined': undefined,
undefined,
'null': null,
'false': false,
'0': 0,

View File

@ -38,7 +38,7 @@ export default {
}
},
watch: {
'$route.query.q': async function (q) {
async '$route.query.q' (q) {
this.searchResults = await search(q)
}
},

View File

@ -21,7 +21,7 @@ export default {
}
},
computed: {
configKeys: function () {
configKeys () {
return Object.keys(this.vueConfig).filter(k => ['silent', 'devtools', 'performance', 'productTip'].includes(k))
}
}

View File

@ -3,7 +3,7 @@
export default {
async asyncData () {
await Promise.resolve()
throw Error('asyncData error!')
throw new Error('asyncData error!')
}
}
</script>

View File

@ -2,7 +2,7 @@
export default {
fetch () {
throw Error('fetch error!')
throw new Error('fetch error!')
}
}
</script>

View File

@ -5,7 +5,7 @@ import { loadFixture, getPort, Nuxt } from '../utils'
let nuxt = null
const readFile = promisify(fs.readFile)
const isWindows = /^win/.test(process.platform)
const isWindows = process.platform.startsWith('win')
describe('extract css', () => {
beforeAll(async () => {

View File

@ -26,12 +26,12 @@ export default class Browser {
}
async close () {
if (!this.browser) return
if (!this.browser) { return }
await this.browser.close()
}
async page (url, globalName = 'nuxt') {
if (!this.browser) throw new Error('Please call start() before page(url)')
if (!this.browser) { throw new Error('Please call start() before page(url)') }
const page = await this.browser.newPage()
await page.goto(url)
page.$nuxtGlobalHandle = `window.$${globalName}`

View File

@ -25,7 +25,7 @@ export default class ChromeDetector {
detect (platform = this.platform) {
const handler = this[platform]
if (typeof handler !== 'function') {
throw new Error(`${platform} is not supported.`)
throw new TypeError(`${platform} is not supported.`)
}
return this[platform]()[0]
}

101
yarn.lock
View File

@ -1654,10 +1654,19 @@
consola "^2.3.0"
node-fetch "^2.3.0"
"@nuxtjs/eslint-config@^0.0.1":
version "0.0.1"
resolved "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-0.0.1.tgz#3aeed1cc6a2e01331c7e6b56bfa7152ce8bb2d90"
integrity sha512-Scz5oYNtVwePF1ebXcWPrFxBpNF5wAkYh8L++6f2ZdLyUb1mCOwzE2+oVZxS25hGCYUyecFEshbqeSwkC+ktqA==
"@nuxtjs/eslint-config@^1.0.1":
version "1.0.1"
resolved "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-1.0.1.tgz#95723021cfe436cee71ee24507ce014ddfa38449"
integrity sha512-hKN8OEAWd119vgI0DtkCD8Q/epIpx41cpCyCx7R7u67tQUdeYF6M6/3TQrQnNPMWCSLQ77AkhZBNnCPpoQIJrw==
dependencies:
eslint-config-standard "^12.0.0"
eslint-plugin-import "^2.18.0"
eslint-plugin-jest "^22.7.2"
eslint-plugin-node "^9.1.0"
eslint-plugin-promise "^4.2.1"
eslint-plugin-standard "^4.0.0"
eslint-plugin-unicorn "^9.1.1"
eslint-plugin-vue "^5.2.3"
"@nuxtjs/youch@^4.2.3":
version "4.2.3"
@ -3418,6 +3427,13 @@ clean-css@4.2.x, clean-css@^4.2.1:
dependencies:
source-map "~0.6.0"
clean-regexp@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz#8df7c7aae51fd36874e8f8d05b9180bc11a3fed7"
integrity sha1-jffHquUf02h06PjQW5GAvBGj/tc=
dependencies:
escape-string-regexp "^1.0.5"
cli-boxes@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143"
@ -4762,6 +4778,14 @@ escodegen@1.x.x, escodegen@^1.11.1, escodegen@^1.9.1:
optionalDependencies:
source-map "~0.6.1"
eslint-ast-utils@^1.0.0:
version "1.1.0"
resolved "https://registry.npmjs.org/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz#3d58ba557801cfb1c941d68131ee9f8c34bd1586"
integrity sha512-otzzTim2/1+lVrlH19EfQQJEhVJSu0zOb9ygb3iapN6UlyaDtyRq4b5U1FuW0v1lRa9Fp/GJyHkSwm6NqABgCA==
dependencies:
lodash.get "^4.4.2"
lodash.zip "^4.2.0"
eslint-config-standard@^12.0.0:
version "12.0.0"
resolved "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-12.0.0.tgz#638b4c65db0bd5a41319f96bba1f15ddad2107d9"
@ -4844,6 +4868,24 @@ eslint-plugin-standard@^4.0.0:
resolved "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.0.tgz#f845b45109c99cd90e77796940a344546c8f6b5c"
integrity sha512-OwxJkR6TQiYMmt1EsNRMe5qG3GsbjlcOhbGUBY4LtavF9DsLaTcoR+j2Tdjqi23oUwKNUqX7qcn5fPStafMdlA==
eslint-plugin-unicorn@^9.1.1:
version "9.1.1"
resolved "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-9.1.1.tgz#1588a0473f9a0e37cfbbcf7552065a0b0a96ce26"
integrity sha512-SHh/N54pRu5KXlS4Boa1qbWM7yTNl6VpuYJ8Qc1O3TJDr+CDUwEEdUtVlVSV/dBUE97BC8Xk0+Y5zphn21qlCA==
dependencies:
clean-regexp "^1.0.0"
eslint-ast-utils "^1.0.0"
import-modules "^1.1.0"
lodash.camelcase "^4.1.1"
lodash.defaultsdeep "^4.6.0"
lodash.kebabcase "^4.0.1"
lodash.snakecase "^4.0.1"
lodash.topairs "^4.3.0"
lodash.upperfirst "^4.2.0"
regexpp "^2.0.1"
reserved-words "^0.1.2"
safe-regex "^2.0.1"
eslint-plugin-vue@^5.2.3:
version "5.2.3"
resolved "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-5.2.3.tgz#3ee7597d823b5478804b2feba9863b1b74273961"
@ -6194,6 +6236,11 @@ import-local@^2.0.0:
pkg-dir "^3.0.0"
resolve-cwd "^2.0.0"
import-modules@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/import-modules/-/import-modules-1.1.0.tgz#748db79c5cc42bb9701efab424f894e72600e9dc"
integrity sha1-dI23nFzEK7lwHvq0JPiU5yYA6dw=
imurmurhash@^0.1.4:
version "0.1.4"
resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"
@ -7508,6 +7555,11 @@ lodash.assignin@^4.2.0:
resolved "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2"
integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI=
lodash.camelcase@^4.1.1:
version "4.3.0"
resolved "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=
lodash.clone@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6"
@ -7518,6 +7570,11 @@ lodash.clonedeep@^4.3.0, lodash.clonedeep@^4.5.0:
resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
lodash.defaultsdeep@^4.6.0:
version "4.6.1"
resolved "https://registry.npmjs.org/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.1.tgz#512e9bd721d272d94e3d3a63653fa17516741ca6"
integrity sha512-3j8wdDzYuWO3lM3Reg03MuQR957t287Rpcxp1njpEa8oDrikb+FwGdW3n+FELh/A6qib6yPit0j/pv9G/yeAqA==
lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
@ -7533,7 +7590,7 @@ lodash.ismatch@^4.4.0:
resolved "https://registry.npmjs.org/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37"
integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc=
lodash.kebabcase@^4.1.1:
lodash.kebabcase@^4.0.1, lodash.kebabcase@^4.1.1:
version "4.1.1"
resolved "https://registry.npmjs.org/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36"
integrity sha1-hImxyw0p/4gZXM7KRI/21swpXDY=
@ -7548,6 +7605,11 @@ lodash.set@^4.3.2:
resolved "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
lodash.snakecase@^4.0.1:
version "4.1.1"
resolved "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d"
integrity sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@ -7568,11 +7630,26 @@ lodash.templatesettings@^4.0.0:
dependencies:
lodash._reinterpolate "^3.0.0"
lodash.topairs@^4.3.0:
version "4.3.0"
resolved "https://registry.npmjs.org/lodash.topairs/-/lodash.topairs-4.3.0.tgz#3b6deaa37d60fb116713c46c5f17ea190ec48d64"
integrity sha1-O23qo31g+xFnE8RsXxfqGQ7EjWQ=
lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
lodash.upperfirst@^4.2.0:
version "4.3.1"
resolved "https://registry.npmjs.org/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce"
integrity sha1-E2Xt9DFIBIHvDRxolXpe2Z1J984=
lodash.zip@^4.2.0:
version "4.2.0"
resolved "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020"
integrity sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=
lodash@4.17.11:
version "4.17.11"
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
@ -10216,7 +10293,7 @@ regex-not@^1.0.0, regex-not@^1.0.2:
extend-shallow "^3.0.2"
safe-regex "^1.1.0"
regexp-tree@^0.1.6:
regexp-tree@^0.1.6, regexp-tree@~0.1.1:
version "0.1.11"
resolved "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.11.tgz#c9c7f00fcf722e0a56c7390983a7a63dd6c272f3"
integrity sha512-7/l/DgapVVDzZobwMCCgMlqiqyLFJ0cduo/j+3BcDJIB+yJdsYCfKuI3l/04NV+H/rfNRdPIDbXNZHM9XvQatg==
@ -10360,6 +10437,11 @@ require-main-filename@^2.0.0:
resolved "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
reserved-words@^0.1.2:
version "0.1.2"
resolved "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz#00a0940f98cd501aeaaac316411d9adc52b31ab1"
integrity sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=
resolve-cwd@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
@ -10564,6 +10646,13 @@ safe-regex@^1.1.0:
dependencies:
ret "~0.1.10"
safe-regex@^2.0.1:
version "2.0.2"
resolved "https://registry.npmjs.org/safe-regex/-/safe-regex-2.0.2.tgz#3601b28d3aefe4b963d42f6c2cdb241265cbd63c"
integrity sha512-rRALJT0mh4qVFIJ9HvfjKDN77F9vp7kltOpFFI/8e6oKyHFmmxz4aSkY/YVauRDe7U0RrHdw9Lsxdel3E19s0A==
dependencies:
regexp-tree "~0.1.1"
"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0:
version "2.1.2"
resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"