Skip to content

Commit 631f0ea

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[cleanup] Remove deprecated functions in EsLint rule
This remove some deprecated functions that were still around after the v9 migration, which will be remove in the next Major Also adds types to some places to remove some anys from the code. Bug: none Change-Id: I668c4f92566fb838cb99c740458e316447d1fdb1 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6730900 Auto-Submit: Nikolay Vitkov <[email protected]> Reviewed-by: Danil Somsikov <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 09317e3 commit 631f0ea

21 files changed

+55
-44
lines changed

scripts/eslint_rules/lib/check-css-import.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default createRule({
2828
},
2929
defaultOptions: [],
3030
create: function(context) {
31-
const filename = context.getFilename();
31+
const filename = context.filename;
3232
return {
3333
ImportDeclaration(node) {
3434
const importPath = path.normalize(`${node.source.value}`);

scripts/eslint_rules/lib/check-license-header.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ export default createRule({
149149
},
150150
defaultOptions: [],
151151
create: function(context) {
152-
const sourceCode = context.sourceCode ?? context.getSourceCode();
153-
const filename = context.filename ?? context.getFilename();
152+
const sourceCode = context.sourceCode;
153+
const filename = context.filename;
154154
const fileName = filename;
155155
// Fix windows paths for exemptions
156156
const relativePath = path.relative(FRONT_END_FOLDER, fileName).replace(/\\/g, '/');

scripts/eslint_rules/lib/check-test-definitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default createRule({
4141
},
4242
defaultOptions: [],
4343
create: function(context) {
44-
const sourceCode = context.sourceCode ?? context.getSourceCode();
44+
const sourceCode = context.sourceCode;
4545
return {
4646
MemberExpression(node) {
4747
if (node.object.type !== 'Identifier' || node.property.type !== 'Identifier') {

scripts/eslint_rules/lib/enforce-custom-element-definitions-location.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default createRule<[{rootFrontendDirectory: string}], 'definitionInWrongF
3535
},
3636
defaultOptions: [{rootFrontendDirectory: ''}],
3737
create: function(context) {
38-
const filename = context.filename ?? context.getFilename();
38+
const filename = context.filename;
3939
const classDefiningFileName = path.resolve(filename);
4040

4141
let frontEndDirectory = '';

scripts/eslint_rules/lib/html-tagged-template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ export default createRule({
2525
},
2626
defaultOptions: [],
2727
create: function(context) {
28-
const sourceCode = context.sourceCode ?? context.getSourceCode();
28+
const sourceCode = context.sourceCode;
2929
let lastImport: ImportDeclaration|null = null;
3030
let shorthandDefined = false;
3131
return {
3232
ImportDeclaration(node) {
3333
lastImport = node;
3434
},
3535
VariableDeclarator(node) {
36-
const scope = sourceCode.getScope ? sourceCode.getScope(node) : context.getScope();
36+
const scope = sourceCode.getScope(node);
3737
if (scope.type !== 'module') {
3838
return;
3939
}

scripts/eslint_rules/lib/inline-type-imports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default createRule({
8383
}
8484
const importStart = valueImportNode.range[0];
8585
// Find the 'type' keyword after 'import'. It should be the first token after 'import'.
86-
const sourceCode = context.sourceCode ?? context.getSourceCode();
86+
const sourceCode = context.sourceCode;
8787
const importToken = sourceCode.getFirstToken(valueImportNode);
8888
const typeToken = importToken ? sourceCode.getTokenAfter(importToken) : null;
8989

scripts/eslint_rules/lib/no-commented-out-console.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default createRule({
2020
},
2121
defaultOptions: [],
2222
create: function(context) {
23-
const sourceCode = context.sourceCode ?? context.getSourceCode();
23+
const sourceCode = context.sourceCode;
2424

2525
function checkCommentAndReportError(comment) {
2626
const trimmed = comment.value.trim();

scripts/eslint_rules/lib/no-imperative-dom-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default createRule({
6363
},
6464
defaultOptions: [],
6565
create: function(context) {
66-
const sourceCode = context.getSourceCode();
66+
const sourceCode = context.sourceCode;
6767

6868
const subrules: Subrule[] = [
6969
adorner.create(context),

scripts/eslint_rules/lib/no-imperative-dom-api/adorner.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
import type {TSESTree} from '@typescript-eslint/utils';
99

10-
import {isIdentifier, isIdentifierChain} from './ast.ts';
10+
import {type Context, isIdentifier, isIdentifierChain} from './ast.ts';
1111
import {DomFragment} from './dom-fragment.ts';
12+
1213
type Identifier = TSESTree.Identifier;
1314
type Node = TSESTree.Node;
1415

1516
export const adorner = {
16-
create(context) {
17-
const sourceCode = context.getSourceCode();
17+
create(context: Context) {
18+
const sourceCode = context.sourceCode;
1819
return {
1920
propertyAssignment(property: Identifier, propertyValue: Node, domFragment: DomFragment) {
2021
if (domFragment.tagName === 'devtools-adorner' && isIdentifier(property, 'data') &&

scripts/eslint_rules/lib/no-imperative-dom-api/aria-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
import type {TSESTree} from '@typescript-eslint/utils';
99

10-
import {isIdentifier, isIdentifierChain, isMemberExpression} from './ast.ts';
10+
import {type Context, isIdentifier, isIdentifierChain, isMemberExpression} from './ast.ts';
1111
import type {DomFragment} from './dom-fragment.ts';
1212

1313
type Node = TSESTree.Node;
1414
type CallExpression = TSESTree.CallExpression;
1515
type Identifier = TSESTree.Identifier;
1616

1717
export const ariaUtils = {
18-
create(_) {
18+
create(_context: Context) {
1919
return {
2020
functionCall(call: CallExpression, _firstArg: Node, secondArg: Node, domFragment: DomFragment): boolean {
2121
const func = isMemberExpression(

0 commit comments

Comments
 (0)