Skip to content

Commit

Permalink
workflow: enable eslint node/no-extraneous-require
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 30, 2018
1 parent ef2ecf5 commit 7ce91c8
Show file tree
Hide file tree
Showing 25 changed files with 68 additions and 36 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ template
packages/test
temp
entry-wc.js
dist
9 changes: 0 additions & 9 deletions .eslintrc

This file was deleted.

29 changes: 29 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = {
extends: [
"plugin:vue-libs/recommended"
],
plugins: [
"node"
],
env: {
"jest": true
},
rules: {
"indent": ["error", 2, {
"MemberExpression": "off"
}],
"node/no-extraneous-require": ["error", {
"allowModules": [
"@vue/cli-test-utils"
]
}]
},
overrides: [
{
files: ['**/__tests__/**/*.js', "**/cli-test-utils/**/*.js"],
rules: {
"node/no-extraneous-require": "off"
}
}
]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"babel-core": "7.0.0-bridge.0",
"debug": "^3.1.0",
"eslint": "^4.16.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-vue-libs": "^2.1.0",
"globby": "^8.0.1",
"http-server": "^0.11.1",
Expand Down
24 changes: 12 additions & 12 deletions packages/@vue/cli-plugin-e2e-cypress/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
const chalk = require('chalk')
module.exports = (api, options) => {
const { info, chalk, execa } = require('@vue/cli-shared-utils')

function removeArg (rawArgs, arg) {
const matchRE = new RegExp(`^--${arg}`)
const equalRE = new RegExp(`^--${arg}=`)
const i = rawArgs.findIndex(arg => matchRE.test(arg))
if (i > -1) {
rawArgs.splice(i, equalRE.test(rawArgs[i]) ? 1 : 2)
}
}
console.log(require('@vue/cli-shared-utils'))

module.exports = (api, options) => {
api.registerCommand('test:e2e', {
description: 'run e2e tests with Cypress',
usage: 'vue-cli-service test:e2e [options]',
Expand All @@ -27,7 +20,6 @@ module.exports = (api, options) => {
removeArg(rawArgs, 'mode')
removeArg(rawArgs, 'url')

const { info } = require('@vue/cli-shared-utils')
info(`Starting e2e tests...`)

const { url, server } = args.url
Expand All @@ -40,7 +32,6 @@ module.exports = (api, options) => {
...rawArgs
]

const execa = require('execa')
const cypressBinPath = require.resolve('cypress/bin/cypress')
const runner = execa(cypressBinPath, cyArgs, { stdio: 'inherit' })
if (server) {
Expand Down Expand Up @@ -68,3 +59,12 @@ module.exports = (api, options) => {
module.exports.defaultModes = {
'test:e2e': 'production'
}

function removeArg (rawArgs, arg) {
const matchRE = new RegExp(`^--${arg}`)
const equalRE = new RegExp(`^--${arg}=`)
const i = rawArgs.findIndex(arg => matchRE.test(arg))
if (i > -1) {
rawArgs.splice(i, equalRE.test(rawArgs[i]) ? 1 : 2)
}
}
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-e2e-cypress/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"access": "public"
},
"dependencies": {
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"cypress": "^2.1.0",
"eslint-plugin-cypress": "^2.0.1"
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-e2e-nightwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"access": "public"
},
"dependencies": {
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"chromedriver": "^2.38.3",
"deepmerge": "^2.1.0",
"execa": "^0.10.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-plugin-eslint/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ const renamedArgs = {

module.exports = function lint (args = {}, api) {
const path = require('path')
const chalk = require('chalk')
const cwd = api.resolve('.')
const { CLIEngine } = require('eslint')
const { log, done, exit } = require('@vue/cli-shared-utils')
const { log, done, exit, chalk } = require('@vue/cli-shared-utils')

const files = args._ && args._.length ? args._ : ['src', 'tests', '*.js']
const extensions = require('./eslintOptions').extensions(api)
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"access": "public"
},
"dependencies": {
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-loader": "^2.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-plugin-eslint/prompts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// these prompts are used if the plugin is late-installed into an existing
// project and invoked by `vue invoke`.

const chalk = require('chalk')
const { hasGit } = require('@vue/cli-shared-utils')
const { chalk, hasGit } = require('@vue/cli-shared-utils')

module.exports = [
{
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-pwa/generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = api => {
api.render('./template')

if (api.invoking && api.hasPlugin('typescript')) {
/* eslint-disable-next-line node/no-extraneous-require */
const convertFiles = require('@vue/cli-plugin-typescript/generator/convert')
convertFiles(api)
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-typescript/lib/tslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function lint (args = {}, api, silent) {
const path = require('path')
const globby = require('globby')
const tslint = require('tslint')
/* eslint-disable-next-line node/no-extraneous-require */
const vueCompiler = require('vue-template-compiler')

const options = {
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-plugin-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@types/node": "^9.3.0",
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"fork-ts-checker-webpack-plugin": "^0.4.1",
"globby": "^8.0.1",
"ts-loader": "^4.3.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-plugin-typescript/prompts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// these prompts are used if the plugin is late-installed into an existing
// project and invoked by `vue invoke`.

const chalk = require('chalk')
const { hasGit } = require('@vue/cli-shared-utils')
const { chalk, hasGit } = require('@vue/cli-shared-utils')

module.exports = [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-jest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = api => {
process.env.VUE_CLI_BABEL_TARGET_NODE = true
process.env.VUE_CLI_BABEL_TRANSPILE_MODULES = true

const execa = require('execa')
const { execa } = require('@vue/cli-shared-utils')
const jestBinPath = require.resolve('jest/bin/jest')

return new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"access": "public"
},
"dependencies": {
"execa": "^0.10.0",
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"jest": "^22.4.3",
"jest-serializer-vue": "^1.0.0",
"jest-transform-stub": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-mocha/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = api => {
// for @vue/babel-preset-app
process.env.VUE_CLI_BABEL_TARGET_NODE = true
// start runner
const execa = require('execa')
const { execa } = require('@vue/cli-shared-utils')
const bin = require.resolve('mocha-webpack/bin/mocha-webpack')
const hasInlineFilesGlob = args._ && args._.length
const argv = [
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-plugin-unit-mocha/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"homepage": "https://github.com/vuejs/vue-cli/packages/@vue/cli-plugin-unit-mocha#readme",
"dependencies": {
"execa": "^0.10.0",
"@vue/cli-shared-utils": "^3.0.0-beta.14",
"jsdom": "^11.10.0",
"jsdom-global": "^3.0.2",
"mocha": "^5.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/generator/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = (api, options) => {
})

if (api.hasPlugin('typescript')) {
/* eslint-disable-next-line node/no-extraneous-require */
const convertFiles = require('@vue/cli-plugin-typescript/generator/convert')
convertFiles(api)
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/generator/vuex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = (api, options) => {
api.render('./template')

if (api.invoking && api.hasPlugin('typescript')) {
/* eslint-disable-next-line node/no-extraneous-require */
const convertFiles = require('@vue/cli-plugin-typescript/generator/convert')
convertFiles(api)
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/lib/config/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = (api, options) => {
// vue-loader --------------------------------------------------------------
const vueLoaderCacheConfig = api.genCacheConfig('vue-loader', {
'vue-loader': require('vue-loader/package.json').version,
/* eslint-disable-next-line node/no-extraneous-require */
'@vue/component-compiler-utils': require('@vue/component-compiler-utils/package.json').version,
'vue-template-compiler': require('vue-template-compiler/package.json').version
})
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"cliui": "^4.1.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"debug": "^3.1.0",
"escape-string-regexp": "^1.0.5",
"file-loader": "^1.1.11",
"friendly-errors-webpack-plugin": "^1.7.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/@vue/cli-shared-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
].forEach(m => {
Object.assign(exports, require(`./lib/${m}`))
})

exports.chalk = require('chalk')
exports.execa = require('execa')
exports.cmdShim = require('util').promisify(require('cmd-shim'))
6 changes: 3 additions & 3 deletions packages/@vue/cli/lib/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const chalk = require('chalk')
const invoke = require('./invoke')
const { loadOptions } = require('./options')
const { installPackage } = require('./util/installDeps')
const { resolveModule } = require('./util/module')
const { resolveModule, loadModule } = require('./util/module')
const {
log,
error,
Expand Down Expand Up @@ -46,14 +46,14 @@ async function add (pluginName, options = {}, context = process.cwd()) {
async function addRouter (context) {
invoke.runGenerator(context, {
id: 'core:router',
apply: require('@vue/cli-service/generator/router')
apply: loadModule('@vue/cli-service/generator/router', context)
})
}

async function addVuex (context) {
invoke.runGenerator(context, {
id: 'core:vuex',
apply: require('@vue/cli-service/generator/vuex')
apply: loadModule('@vue/cli-service/generator/vuex', context)
})
}

Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli/lib/util/linkBin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

const fs = require('fs-extra')
const path = require('path')
const { promisify } = require('util')
const cmdShim = promisify(require('cmd-shim'))
const { cmdShim } = require('@vue/cli-shared-utils')

exports.linkBin = async (src, dest) => {
if (!process.env.VUE_CLI_TEST && !process.env.VUE_CLI_DEBUG) {
Expand Down

0 comments on commit 7ce91c8

Please sign in to comment.