Skip to content

Commit cdb1d17

Browse files
authored
chore: disallow optional chaining (#10919)
1 parent 94b9b37 commit cdb1d17

File tree

6 files changed

+18
-1
lines changed

6 files changed

+18
-1
lines changed

eslint.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ export default tseslint.config(
4545
message:
4646
'Our output target is ES2016, so async/await syntax should be avoided.',
4747
},
48+
{
49+
selector: 'ChainExpression',
50+
message:
51+
'Our output target is ES2016, and optional chaining results in ' +
52+
'verbose helpers and should be avoided.',
53+
},
4854
],
4955
'sort-imports': ['error', { ignoreDeclarationSort: true }],
5056

@@ -134,7 +140,7 @@ export default tseslint.config(
134140
{
135141
files: [
136142
'eslint.config.js',
137-
'rollup.config.js',
143+
'rollup*.config.js',
138144
'scripts/**',
139145
'./*.{js,ts}',
140146
'packages/*/*.js',

packages/compiler-core/src/babelUtils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export function walkIdentifiers(
5353
}
5454
} else if (
5555
node.type === 'ObjectProperty' &&
56+
// eslint-disable-next-line no-restricted-syntax
5657
parent?.type === 'ObjectPattern'
5758
) {
5859
// mark property in destructure pattern
@@ -407,6 +408,7 @@ function isReferenced(node: Node, parent: Node, grandparent?: Node): boolean {
407408
// no: export { NODE as foo } from "foo";
408409
case 'ExportSpecifier':
409410
// @ts-expect-error
411+
// eslint-disable-next-line no-restricted-syntax
410412
if (grandparent?.source) {
411413
return false
412414
}

packages/reactivity/src/effect.ts

+2
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ export function trackEffect(
281281
effect._depsLength++
282282
}
283283
if (__DEV__) {
284+
// eslint-disable-next-line no-restricted-syntax
284285
effect.onTrack?.(extend({ effect }, debuggerEventExtraInfo!))
285286
}
286287
}
@@ -309,6 +310,7 @@ export function triggerEffects(
309310
(tracking ??= dep.get(effect) === effect._trackId)
310311
) {
311312
if (__DEV__) {
313+
// eslint-disable-next-line no-restricted-syntax
312314
effect.onTrigger?.(extend({ effect }, debuggerEventExtraInfo))
313315
}
314316
effect.trigger()

packages/runtime-core/src/devtools.ts

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function setDevtoolsHook(hook: DevtoolsHook, target: any) {
6363
// some envs mock window but not fully
6464
window.HTMLElement &&
6565
// also exclude jsdom
66+
// eslint-disable-next-line no-restricted-syntax
6667
!window.navigator?.userAgent?.includes('jsdom')
6768
) {
6869
const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =

packages/runtime-core/src/hydration.ts

+5
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,14 @@ function propHasMismatch(
757757
}
758758
}
759759

760+
// eslint-disable-next-line no-restricted-syntax
760761
const root = instance?.subTree
761762
if (
762763
vnode === root ||
764+
// eslint-disable-next-line no-restricted-syntax
763765
(root?.type === Fragment && (root.children as VNode[]).includes(vnode))
764766
) {
767+
// eslint-disable-next-line no-restricted-syntax
765768
const cssVars = instance?.getCssVars?.()
766769
for (const key in cssVars) {
767770
expectedMap.set(`--${key}`, String(cssVars[key]))
@@ -842,7 +845,9 @@ function toStyleMap(str: string): Map<string, string> {
842845
const styleMap: Map<string, string> = new Map()
843846
for (const item of str.split(';')) {
844847
let [key, value] = item.split(':')
848+
// eslint-disable-next-line no-restricted-syntax
845849
key = key?.trim()
850+
// eslint-disable-next-line no-restricted-syntax
846851
value = value?.trim()
847852
if (key && value) {
848853
styleMap.set(key, value)

packages/runtime-core/src/warning.ts

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export function warn(msg: string, ...args: any[]) {
4545
instance,
4646
ErrorCodes.APP_WARN_HANDLER,
4747
[
48+
// eslint-disable-next-line no-restricted-syntax
4849
msg + args.map(a => a.toString?.() ?? JSON.stringify(a)).join(''),
4950
instance && instance.proxy,
5051
trace

0 commit comments

Comments
 (0)