54727f9874
e.g. by replacing `__VUE_OPTIONS_API__` to `false` using webpack's `DefinePlugin`, the final bundle will drop all code supporting the options API. This does not break existing usage, but requires the user to explicitly configure the feature flags via bundlers to properly tree-shake the disabled branches. As a result, users will see a console warning if the flags have not been properly configured.
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
const DOMGlobals = ['window', 'document']
|
|
const NodeGlobals = ['module', 'require']
|
|
|
|
module.exports = {
|
|
parser: '@typescript-eslint/parser',
|
|
parserOptions: {
|
|
sourceType: 'module'
|
|
},
|
|
rules: {
|
|
'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', argsIgnorePattern: '^_' }
|
|
],
|
|
// 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: [
|
|
// tests, no restrictions (runs in Node / jest with jsdom)
|
|
{
|
|
files: ['**/__tests__/**', 'test-dts/**'],
|
|
rules: {
|
|
'no-restricted-globals': 'off',
|
|
'no-restricted-syntax': 'off'
|
|
}
|
|
},
|
|
// shared, may be used in any env
|
|
{
|
|
files: ['packages/shared/**'],
|
|
rules: {
|
|
'no-restricted-globals': 'off'
|
|
}
|
|
},
|
|
// 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'
|
|
}
|
|
},
|
|
// Private package, browser only + no syntax restrictions
|
|
{
|
|
files: ['packages/template-explorer/**'],
|
|
rules: {
|
|
'no-restricted-globals': ['error', ...NodeGlobals],
|
|
'no-restricted-syntax': 'off'
|
|
}
|
|
}
|
|
]
|
|
}
|