Browse Source
chore: more descriptive eslint error messages for restricted syntax
pull/10705/head
Evan You
1 year ago
No known key found for this signature in database
GPG Key ID: B9D421896CA450FB
2 changed files with
19 additions and
9 deletions
-
.eslintrc.cjs
-
rollup.config.js
|
|
@ -26,13 +26,23 @@ module.exports = { |
|
|
|
'no-restricted-syntax': [ |
|
|
|
'error', |
|
|
|
banConstEnum, |
|
|
|
// since we target ES2015 for baseline support, we need to forbid object |
|
|
|
// rest spread usage in destructure as it compiles into a verbose helper. |
|
|
|
'ObjectPattern > RestElement', |
|
|
|
// tsc compiles assignment spread into Object.assign() calls, but esbuild |
|
|
|
// still generates verbose helpers, so spread assignment is also prohiboted |
|
|
|
'ObjectExpression > SpreadElement', |
|
|
|
'AwaitExpression', |
|
|
|
{ |
|
|
|
selector: 'ObjectPattern > RestElement', |
|
|
|
message: |
|
|
|
'Our output target is ES2016, and object rest spread results in ' + |
|
|
|
'verbose helpers and should be avoided.', |
|
|
|
}, |
|
|
|
{ |
|
|
|
selector: 'ObjectExpression > SpreadElement', |
|
|
|
message: |
|
|
|
'esbuild transpiles object spread into very verbose inline helpers.\n' + |
|
|
|
'Please use the `extend` helper from @vue/shared instead.', |
|
|
|
}, |
|
|
|
{ |
|
|
|
selector: 'AwaitExpression', |
|
|
|
message: |
|
|
|
'Our output target is ES2016, so async/await syntax should be avoided.', |
|
|
|
}, |
|
|
|
], |
|
|
|
'sort-imports': ['error', { ignoreDeclarationSort: true }], |
|
|
|
|
|
|
|
|
|
@ -331,7 +331,7 @@ function createConfig(format, output, plugins = []) { |
|
|
|
tsconfig: path.resolve(__dirname, 'tsconfig.json'), |
|
|
|
sourceMap: output.sourcemap, |
|
|
|
minify: false, |
|
|
|
target: isServerRenderer || isCJSBuild ? 'es2019' : 'es2015', |
|
|
|
target: isServerRenderer || isCJSBuild ? 'es2019' : 'es2016', |
|
|
|
define: resolveDefine(), |
|
|
|
}), |
|
|
|
...resolveNodePlugins(), |
|
|
@ -367,7 +367,7 @@ function createMinifiedConfig(/** @type {PackageFormat} */ format) { |
|
|
|
terser({ |
|
|
|
module: /^esm/.test(format), |
|
|
|
compress: { |
|
|
|
ecma: 2015, |
|
|
|
ecma: 2016, |
|
|
|
pure_getters: true, |
|
|
|
}, |
|
|
|
safari10: true, |
|
|
|