2020-06-11 04:54:23 +08:00
|
|
|
const DOMGlobals = ['window', 'document']
|
|
|
|
const NodeGlobals = ['module', 'require']
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: 'module'
|
|
|
|
},
|
|
|
|
rules: {
|
2020-06-13 04:31:31 +08:00
|
|
|
'no-unused-vars': [
|
|
|
|
'error',
|
|
|
|
// we are only using this rule to check for unused arguments since TS
|
|
|
|
// catches unused variables but not args.
|
|
|
|
{ varsIgnorePattern: '.*', args: 'after-used' }
|
|
|
|
],
|
2020-06-11 04:54:23 +08:00
|
|
|
// most of the codebase are expected to be env agnostic
|
|
|
|
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
|
|
|
|
// since we target ES2015 for baseline support, we need to forbid object
|
|
|
|
// rest spread usage (both assign and destructure)
|
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
'ObjectExpression > SpreadElement',
|
|
|
|
'ObjectPattern > RestElement'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
overrides: [
|
2020-06-13 03:59:05 +08:00
|
|
|
// tests, no restrictions (runs in Node / jest with jsdom)
|
|
|
|
{
|
|
|
|
files: ['**/__tests__/**'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': 'off',
|
|
|
|
'no-restricted-syntax': 'off'
|
|
|
|
}
|
|
|
|
},
|
2020-06-11 04:54:23 +08:00
|
|
|
// Packages targeting DOM
|
|
|
|
{
|
|
|
|
files: ['packages/{vue,runtime-dom}/**'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': ['error', ...NodeGlobals]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Packages targeting Node
|
|
|
|
{
|
|
|
|
files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': ['error', ...DOMGlobals],
|
|
|
|
'no-restricted-syntax': 'off'
|
|
|
|
}
|
|
|
|
},
|
2020-06-13 03:59:05 +08:00
|
|
|
// Private package, browser only + no syntax restrictions
|
2020-06-11 04:54:23 +08:00
|
|
|
{
|
|
|
|
files: ['packages/template-explorer/**'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': ['error', ...NodeGlobals],
|
|
|
|
'no-restricted-syntax': 'off'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|