-
Notifications
You must be signed in to change notification settings - Fork 15
/
module.js
46 lines (39 loc) · 1.11 KB
/
module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { resolve } = require('path')
const logger = require('./logger')
const { moduleExists } = require('./utils')
module.exports = function (moduleOptions) {
const options = {
context: this.options.srcDir,
eslintPath: 'eslint',
extensions: ['js', 'ts', 'vue'],
cache: true,
lintDirtyModulesOnly: true,
...this.options.eslint,
...moduleOptions
}
if (!moduleExists(options.eslintPath)) {
logger.warn(
`The dependency \`${options.eslintPath}\` not found.`,
'Please run `yarn add eslint --dev` or `npm install eslint --save-dev`'
)
return
}
const filesToWatch = [
'.eslintrc',
'.eslintrc.json',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.js'
]
this.options.watch = this.options.watch || []
this.options.watch.push(
...filesToWatch.map(file => resolve(this.options.rootDir, file))
)
this.extendBuild((config, { isDev, isClient }) => {
if (isDev && isClient) {
const EslintPlugin = require('eslint-webpack-plugin')
config.plugins.push(new EslintPlugin(options))
}
})
}
module.exports.meta = require('../package.json')