Skip to content

Commit 4b76a5f

Browse files
authored
Enable dot-notation rule (#17301)
1 parent 73623f1 commit 4b76a5f

16 files changed

Lines changed: 55 additions & 46 deletions

File tree

.vscode/settings.example.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919
"!**/node_modules/**"
2020
]
2121
},
22-
"[typescript]": {
22+
"[typescript][javascript]": {
2323
"editor.defaultFormatter": "esbenp.prettier-vscode",
2424
"editor.formatOnSave": true,
25-
"editor.codeActionsOnSave": ["source.fixAll.eslint"]
26-
},
27-
"editor.codeActionsOnSave": {
28-
"source.fixAll.eslint": "explicit"
25+
"editor.codeActionsOnSave": {
26+
"source.fixAll.eslint": "explicit"
27+
}
2928
},
3029
"prettier.requireConfig": true
3130
}

eslint.config.mjs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default [
6565
"test/runtime-integration/*/output.js",
6666
"test/runtime-integration/*/output-absolute.js",
6767
"Makefile.mjs",
68+
"packages/babel-types/src/constants/generated/index.ts",
6869
...(process.env.IS_PUBLISH ? testFiles : []),
6970
],
7071
},
@@ -93,6 +94,7 @@ export default [
9394
},
9495
rules: {
9596
curly: ["error", "multi-line"],
97+
"dot-notation": "error",
9698
eqeqeq: ["error", "smart"],
9799
"linebreak-style": ["error", "unix"],
98100
"no-case-declarations": "error",
@@ -201,7 +203,6 @@ export default [
201203
"@typescript-eslint/consistent-generic-constructors": "off",
202204
"@typescript-eslint/consistent-indexed-object-style": "off",
203205
"@typescript-eslint/consistent-type-definitions": "off",
204-
"@typescript-eslint/dot-notation": "off",
205206
"@typescript-eslint/no-base-to-string": "off",
206207
"@typescript-eslint/no-duplicate-type-constituents": "off",
207208
"@typescript-eslint/no-empty-function": "off",
@@ -400,4 +401,16 @@ export default [
400401
reportUnusedDisableDirectives: "off",
401402
},
402403
},
404+
{
405+
files: ["Makefile.source.mjs"],
406+
rules: {
407+
"dot-notation": "off",
408+
},
409+
},
410+
{
411+
files: ["packages/babel-helpers/src/**/*.ts"],
412+
rules: {
413+
"@typescript-eslint/dot-notation": ["error", { allowKeywords: false }],
414+
},
415+
},
403416
];

packages/babel-core/src/config/files/configuration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function buildConfigFileObject(
142142

143143
const packageToBabelConfig = makeWeakCacheSync(
144144
(file: ConfigFile): ConfigFile | null => {
145-
const babel: unknown = file.options["babel"];
145+
const babel: unknown = file.options.babel;
146146

147147
if (babel === undefined) return null;
148148

@@ -178,7 +178,7 @@ const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => {
178178
throw new ConfigError(`Expected config object but found array`, filepath);
179179
}
180180

181-
delete options["$schema"];
181+
delete options.$schema;
182182

183183
return {
184184
filepath,

packages/babel-helper-annotate-as-pure/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function annotateAsPure(
1111
): void {
1212
const node =
1313
// @ts-expect-error Node will not have `node` property
14-
(pathOrNode["node"] || pathOrNode) as Node;
14+
(pathOrNode.node || pathOrNode) as Node;
1515
if (isPureAnnotated(node)) {
1616
return;
1717
}

packages/babel-helpers/src/helpers/applyDecs2305.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ export default /* @no-mangle */ function applyDecs2305(
347347
newValue = _;
348348
}
349349
} else {
350-
ctx.static = isStatic;
351-
ctx.private = isPrivate;
350+
ctx["static"] = isStatic;
351+
ctx["private"] = isPrivate;
352352

353353
var get, set;
354354
if (!isPrivate) {
@@ -542,14 +542,14 @@ export default /* @no-mangle */ function applyDecs2305(
542542
function defineMetadata(Class: any, metadata: any) {
543543
return Object.defineProperty(
544544
Class,
545-
Symbol.metadata || Symbol.for("Symbol.metadata"),
545+
Symbol.metadata || Symbol["for"]("Symbol.metadata"),
546546
{ configurable: true, enumerable: true, value: metadata },
547547
);
548548
}
549549

550550
if (arguments.length >= 6) {
551551
var parentMetadata =
552-
parentClass[Symbol.metadata || Symbol.for("Symbol.metadata")];
552+
parentClass[Symbol.metadata || Symbol["for"]("Symbol.metadata")];
553553
}
554554
var metadata = Object.create(parentMetadata == null ? null : parentMetadata);
555555
var e = applyMemberDecs(targetClass, memberDecs, instanceBrand, metadata);

packages/babel-helpers/src/helpers/applyDecs2311.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default /* @no-mangle */ function applyDecs2311(
203203
instanceBrand: Function,
204204
parentClass: any,
205205
) {
206-
var symbolMetadata = Symbol.metadata || Symbol.for("Symbol.metadata");
206+
var symbolMetadata = Symbol.metadata || Symbol["for"]("Symbol.metadata");
207207
var defineProperty = Object.defineProperty;
208208
var create = Object.create;
209209
var metadata: any;
@@ -392,8 +392,8 @@ export default /* @no-mangle */ function applyDecs2311(
392392
newValue = _;
393393
}
394394
} else {
395-
ctx.static = isStatic;
396-
ctx.private = isPrivate;
395+
ctx["static"] = isStatic;
396+
ctx["private"] = isPrivate;
397397

398398
_ = ctx.access = {
399399
has: isPrivate

packages/babel-helpers/src/helpers/asyncGeneratorDelegate.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export default function _asyncGeneratorDelegate<T>(inner: Generator<T>) {
3636
return pump("next", value);
3737
};
3838

39-
if (typeof inner.throw === "function") {
40-
iter.throw = function (value: any) {
39+
if (typeof inner["throw"] === "function") {
40+
iter["throw"] = function (value: any) {
4141
if (waiting) {
4242
waiting = false;
4343
throw value;
@@ -46,8 +46,8 @@ export default function _asyncGeneratorDelegate<T>(inner: Generator<T>) {
4646
};
4747
}
4848

49-
if (typeof inner.return === "function") {
50-
iter.return = function (value: any) {
49+
if (typeof inner["return"] === "function") {
50+
iter["return"] = function (value: any) {
5151
if (waiting) {
5252
waiting = false;
5353
return value;

packages/babel-helpers/src/helpers/asyncIterator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function AsyncFromSyncIterator<T, TReturn = any, TNext = undefined>(s: any) {
7575
);
7676
},
7777
return: function (value) {
78-
var ret = this.s.return;
78+
var ret = this.s["return"];
7979
if (ret === undefined) {
8080
return Promise.resolve<IteratorReturnResult<TReturn>>({
8181
// "TReturn | PromiseLike<TReturn>" should have been unwrapped by Awaited<T>,
@@ -94,7 +94,7 @@ function AsyncFromSyncIterator<T, TReturn = any, TNext = undefined>(s: any) {
9494
);
9595
},
9696
throw: function (maybeError?: any) {
97-
var thr = this.s.return;
97+
var thr = this.s["return"];
9898
if (thr === undefined) {
9999
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
100100
return Promise.reject(maybeError);

packages/babel-helpers/src/helpers/createForOfIteratorHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export default function _createForOfIteratorHelper<T>(
7878
},
7979
f: function () {
8080
try {
81-
if (!normalCompletion && (it as Iterator<T>).return != null) {
82-
(it as Iterator<T>).return!();
81+
if (!normalCompletion && (it as Iterator<T>)["return"] != null) {
82+
(it as Iterator<T>)["return"]!();
8383
}
8484
} finally {
8585
// eslint-disable-next-line no-unsafe-finally

packages/babel-helpers/src/helpers/usingCtx.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ export default function _usingCtx(): UsingCtxReturn {
6565
// Try AsyncDisposable first
6666
var dispose: DisposeLike | null | undefined = (
6767
value as AsyncDisposable
68-
)[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
68+
)[Symbol.asyncDispose || Symbol["for"]("Symbol.asyncDispose")];
6969
}
7070
if (dispose === undefined) {
7171
dispose = (value as Disposable)[
72-
Symbol.dispose || Symbol.for("Symbol.dispose")
72+
Symbol.dispose || Symbol["for"]("Symbol.dispose")
7373
];
7474
if (isAwait) {
7575
var inner = dispose;

0 commit comments

Comments
 (0)