Skip to content

Commit fff7b86

Browse files
authoredNov 29, 2023
feat: use enum to replace const enum (#9261)
close #1228
1 parent 47ea285 commit fff7b86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+397
-333
lines changed
 

‎.eslintrc.cjs

+13-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
const DOMGlobals = ['window', 'document']
44
const NodeGlobals = ['module', 'require']
55

6+
const banConstEnum = {
7+
selector: 'TSEnumDeclaration[const=true]',
8+
message:
9+
'Please use non-const enums. This project automatically inlines enums.'
10+
}
11+
12+
/**
13+
* @type {import('eslint-define-config').ESLintConfig}
14+
*/
615
module.exports = {
716
parser: '@typescript-eslint/parser',
817
parserOptions: {
@@ -16,6 +25,7 @@ module.exports = {
1625

1726
'no-restricted-syntax': [
1827
'error',
28+
banConstEnum,
1929
// since we target ES2015 for baseline support, we need to forbid object
2030
// rest spread usage in destructure as it compiles into a verbose helper.
2131
'ObjectPattern > RestElement',
@@ -55,15 +65,15 @@ module.exports = {
5565
files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
5666
rules: {
5767
'no-restricted-globals': ['error', ...DOMGlobals],
58-
'no-restricted-syntax': 'off'
68+
'no-restricted-syntax': ['error', banConstEnum]
5969
}
6070
},
6171
// Private package, browser only + no syntax restrictions
6272
{
6373
files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
6474
rules: {
6575
'no-restricted-globals': ['error', ...NodeGlobals],
66-
'no-restricted-syntax': 'off'
76+
'no-restricted-syntax': ['error', banConstEnum]
6777
}
6878
},
6979
// JavaScript files
@@ -79,7 +89,7 @@ module.exports = {
7989
files: ['scripts/**', '*.{js,ts}', 'packages/**/index.js'],
8090
rules: {
8191
'no-restricted-globals': 'off',
82-
'no-restricted-syntax': 'off'
92+
'no-restricted-syntax': ['error', banConstEnum]
8393
}
8494
}
8595
]

‎package.json

+3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
"@rollup/plugin-replace": "^5.0.4",
6767
"@rollup/plugin-terser": "^0.4.4",
6868
"@types/hash-sum": "^1.0.2",
69+
"@types/minimist": "^1.2.5",
6970
"@types/node": "^20.10.0",
71+
"@types/semver": "^7.5.5",
7072
"@typescript-eslint/parser": "^6.13.0",
7173
"@vitest/coverage-istanbul": "^0.34.6",
7274
"@vue/consolidate": "0.17.3",
@@ -75,6 +77,7 @@
7577
"esbuild": "^0.19.5",
7678
"esbuild-plugin-polyfill-node": "^0.3.0",
7779
"eslint": "^8.54.0",
80+
"eslint-define-config": "^1.24.1",
7881
"eslint-plugin-jest": "^27.6.0",
7982
"estree-walker": "^2.0.2",
8083
"execa": "^8.0.1",

0 commit comments

Comments
 (0)
Please sign in to comment.