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.
|
2020-09-16 22:53:02 +08:00
|
|
|
{ varsIgnorePattern: '.*', args: 'none' }
|
2020-06-13 04:31:31 +08:00
|
|
|
],
|
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)
|
|
|
|
{
|
2020-06-30 00:26:28 +08:00
|
|
|
files: ['**/__tests__/**', 'test-dts/**'],
|
2020-06-13 03:59:05 +08:00
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': 'off',
|
|
|
|
'no-restricted-syntax': 'off'
|
|
|
|
}
|
|
|
|
},
|
2020-07-21 09:51:30 +08:00
|
|
|
// shared, may be used in any env
|
|
|
|
{
|
|
|
|
files: ['packages/shared/**'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': '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
|
|
|
{
|
2021-03-28 13:35:45 +08:00
|
|
|
files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
|
2020-06-11 04:54:23 +08:00
|
|
|
rules: {
|
|
|
|
'no-restricted-globals': ['error', ...NodeGlobals],
|
|
|
|
'no-restricted-syntax': 'off'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|