Skip to content

Commit de07efa

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
[eslint] Update lint to include .mjs files
EsLint support .mjs file by default now. But we exclude them from running previously in our script. Disabled the `es-modules-import` rule for our script folder as it's not relevant there. Added types comment to the EsLint rules. This should make it easier to build and understand the current rules. Bug: none Change-Id: I448efdb055c9cc107e3bced9b3febe5eb226bcf6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6177719 Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent 8813805 commit de07efa

File tree

61 files changed

+202
-54
lines changed

Some content is hidden

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

61 files changed

+202
-54
lines changed

eslint.config.mjs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2025 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
15
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
26
import mochaPlugin from 'eslint-plugin-mocha';
37
import rulesdirPlugin from 'eslint-plugin-rulesdir';
@@ -248,10 +252,7 @@ export default [
248252
'rulesdir/no-commented-out-console': 'error',
249253
// Prevent imports being commented out rather than deleted.
250254
'rulesdir/no-commented-out-import': 'error',
251-
// DevTools specific rules
252-
'rulesdir/es-modules-import': 'error',
253255
'rulesdir/check-license-header': 'error',
254-
'rulesdir/html-tagged-template': 'error',
255256
/**
256257
* Ensures that JS Doc comments are properly aligned - all the starting
257258
* `*` are in the right place.
@@ -480,6 +481,7 @@ export default [
480481
files: ['scripts/**/*'],
481482
rules: {
482483
'no-console': 'off',
484+
'rulesdir/es-modules-import': 'off',
483485
},
484486
},
485487
{
@@ -531,6 +533,8 @@ export default [
531533
'rulesdir/lit-template-result-or-nothing': 'error',
532534
'rulesdir/inject-checkbox-styles': 'error',
533535
'rulesdir/jslog-context-list': 'error',
536+
'rulesdir/es-modules-import': 'error',
537+
'rulesdir/html-tagged-template': 'error',
534538
},
535539
},
536540
{

front_end/Images/rollup.config.mjs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright 2021 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// eslint-disable-next-line rulesdir/es-modules-import
54
import {importMetaAssets} from '@web/rollup-plugin-import-meta-assets';
65
import {optimize} from 'svgo';
76

inspector_overlay/css_grid_label_helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
import {luminance} from '../front_end/core/common/ColorUtils.js'; // eslint-disable-line rulesdir/es-modules-import
5+
import {luminance} from '../front_end/core/common/ColorUtils.js';
66

77
import {type AreaBounds, type Bounds, createChild, type Position} from './common.js';
88
import {applyMatrixToPoint, parseHexa} from './highlight_common.js';

inspector_overlay/highlight_common.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2929
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31-
// eslint-disable-next-line rulesdir/es-modules-import
3231
import {
3332
type Color4D,
3433
rgbaToHsla,

inspector_overlay/main.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
// found in the LICENSE file.
44

55
// @ts-ignore Importing CSS is handled in Rollup.
6-
import commonStyle from './common.css'; // eslint-disable-line rulesdir/es-modules-import
6+
import commonStyle from './common.css';
77
import {adoptStyleSheet} from './common.js';
88
import {gridStyle} from './highlight_grid_common.js';
99
import {DistancesOverlay} from './tool_distances.js';
1010
// @ts-ignore Importing CSS is handled in Rollup.
11-
import highlightGridStyle from './tool_grid.css'; // eslint-disable-line rulesdir/es-modules-import
11+
import highlightGridStyle from './tool_grid.css';
1212
// @ts-ignore Importing CSS is handled in Rollup.
13-
import highlightStyle from './tool_highlight.css'; // eslint-disable-line rulesdir/es-modules-import
13+
import highlightStyle from './tool_highlight.css';
1414
import {HighlightOverlay} from './tool_highlight.js';
1515
// @ts-ignore Importing CSS is handled in Rollup.
16-
import pausedStyle from './tool_paused.css'; // eslint-disable-line rulesdir/es-modules-import
16+
import pausedStyle from './tool_paused.css';
1717
import {PausedOverlay, type PausedToolMessage} from './tool_paused.js';
1818
import {PersistentOverlay, type PersistentToolMessage} from './tool_persistent.js';
1919
// @ts-ignore Importing CSS is handled in Rollup.
20-
import screenshotStyle from './tool_screenshot.css'; // eslint-disable-line rulesdir/es-modules-import
20+
import screenshotStyle from './tool_screenshot.css';
2121
import {ScreenshotOverlay, type ScreenshotToolMessage} from './tool_screenshot.js';
2222
// @ts-ignore Importing CSS is handled in Rollup.
23-
import sourceOrderStyle from './tool_source_order.css'; // eslint-disable-line rulesdir/es-modules-import
23+
import sourceOrderStyle from './tool_source_order.css';
2424
import {SourceOrderOverlay} from './tool_source_order.js';
2525
import {ViewportSizeOverlay} from './tool_viewport_size.js';
2626
// @ts-ignore Importing CSS is handled in Rollup.
27-
import wcoStyle from './tool_window_controls.css'; // eslint-disable-line rulesdir/es-modules-import
27+
import wcoStyle from './tool_window_controls.css';
2828
import {WindowControlsOverlay} from './tool_window_controls.js';
2929

3030
// @ts-ignore Importing CSS is handled in Rollup.

inspector_overlay/tool_highlight.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2929
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

31-
// eslint-disable-next-line rulesdir/es-modules-import
3231
import {
3332
contrastRatio,
3433
contrastRatioAPCA,

scripts/ai_assistance/to_tsv.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
65
// Converts a JSON results file into two TSV files: queries and responses.
76
// Usage: node to_tsv.mjs path/to/file.json
87

@@ -22,7 +21,7 @@ function formatRequest(request) {
2221
const lines = [
2322
...(request.chat_history || []).map(item => item.text),
2423
request.input,
25-
]
24+
];
2625
return lines.join('\n\n===\n\n');
2726
}
2827

scripts/eslint_rules/lib/canvas-context-tracking.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
'use strict';
66

7+
/**
8+
* @type {import('eslint').Rule.RuleModule}
9+
*/
710
module.exports = {
811
meta: {
912
type: 'problem',

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

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
const fs = require('fs');
1616
const path = require('path');
1717

18+
/**
19+
* @type {import('eslint').Rule.RuleModule}
20+
*/
1821
module.exports = {
1922
meta: {
2023
type: 'problem',

scripts/eslint_rules/lib/check-enumerated-histograms.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// found in the LICENSE file.
44
'use strict';
55

6+
/**
7+
* @type {import('eslint').Rule.RuleModule}
8+
*/
69
module.exports = {
710
meta: {
811
type: 'problem',

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

+3
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ function isMissingBlockLineCommentLicense(licenseText) {
124124
return !BLOCK_REGEX.test(licenseText);
125125
}
126126

127+
/**
128+
* @type {import('eslint').Rule.RuleModule}
129+
*/
127130
module.exports = {
128131
meta: {
129132
type: 'problem',

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

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ function getTextValue(node) {
2626
}
2727
}
2828

29+
/**
30+
* @type {import('eslint').Rule.RuleModule}
31+
*/
2932
module.exports = {
3033
meta: {
3134
type: 'problem',

scripts/eslint_rules/lib/check-was-shown-methods.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
'use strict';
66

7+
/**
8+
* @type {import('eslint').Rule.RuleModule}
9+
*/
710
module.exports = {
811
meta: {
912
type: 'problem',

scripts/eslint_rules/lib/enforce-bound-render-for-schedule-render.js

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ function isPropertyDefinitionViaArrowFunction(propertyDefinition) {
6262
return propertyDefinition.value.type === 'ArrowFunctionExpression';
6363
}
6464

65+
/**
66+
* @type {import('eslint').Rule.RuleModule}
67+
*/
6568
module.exports = {
6669
meta: {
6770
type: 'problem',

scripts/eslint_rules/lib/enforce-custom-event-names.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
const VALID_EVENT_NAME_REGEX = /^([a-z]+)$/;
99

10+
/**
11+
* @type {import('eslint').Rule.RuleModule}
12+
*/
1013
module.exports = {
1114
meta: {
1215
type: 'problem',

scripts/eslint_rules/lib/enforce-default-import-name.js

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ function isStarAsImportSpecifier(specifiers) {
1010
return specifiers.length === 1 && specifiers[0].type === 'ImportNamespaceSpecifier';
1111
}
1212

13+
/**
14+
* @type {import('eslint').Rule.RuleModule}
15+
*/
1316
module.exports = {
1417
meta: {
1518
type: 'problem',

scripts/eslint_rules/lib/enforce-optional-properties-last.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
*/
99
'use strict';
1010

11+
/**
12+
* @type {import('eslint').Rule.RuleModule}
13+
*/
1114
module.exports = {
1215
meta: {
1316
type: 'problem',

scripts/eslint_rules/lib/es-modules-import.js

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ function checkStarImport(context, node, importPath, importPathForErrorMessage, i
118118
}
119119
}
120120

121+
/**
122+
* @type {import('eslint').Rule.RuleModule}
123+
*/
121124
module.exports = {
122125
meta: {
123126
type: 'problem',

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

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
/**
6+
* @type {import('eslint').Rule.RuleModule}
7+
*/
58
module.exports = {
69
meta: {
710
type: 'problem',

scripts/eslint_rules/lib/inject-checkbox-styles.js

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const FRONT_END_DIRECTORY = path.join(__dirname, '..', '..', '..', 'front_end');
1212
// input.js as that's what the import statement would reference.
1313
const COMMON_INPUT_STYLES = path.join(FRONT_END_DIRECTORY, 'ui', 'components', 'input', 'input.js');
1414

15+
/**
16+
* @type {import('eslint').Rule.RuleModule}
17+
*/
1518
module.exports = {
1619
meta: {
1720
type: 'problem',

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

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// found in the LICENSE file.
44
'use strict';
55

6+
/**
7+
* @type {import('eslint').Rule.RuleModule}
8+
*/
69
module.exports = {
710
meta: {
811
type: 'problem',

scripts/eslint_rules/lib/jslog-context-list.js

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const LICENSE_HEADER = `// Copyright 2024 The Chromium Authors. All rights reser
1616
1717
`;
1818

19+
/**
20+
* @type {import('eslint').Rule.RuleModule}
21+
*/
1922
module.exports = {
2023
meta: {
2124
type: 'problem',

scripts/eslint_rules/lib/l10n-filename-matches.js

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ function isRegisterUIStringsCall(callExpression) {
2424
return true;
2525
}
2626

27+
/**
28+
* @type {import('eslint').Rule.RuleModule}
29+
*/
2730
module.exports = {
2831
meta: {
2932
type: 'problem',

scripts/eslint_rules/lib/l10n-i18nString-call-only-with-uistrings.js

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function isArgumentValid(argument) {
1919
return argument.object.type === 'Identifier' && argument.object.name === 'UIStrings';
2020
}
2121

22+
/**
23+
* @type {import('eslint').Rule.RuleModule}
24+
*/
2225
module.exports = {
2326
meta: {
2427
type: 'problem',

scripts/eslint_rules/lib/l10n-no-i18nString-calls-module-instantiation.js

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ function isI18nStringCall(callExpression) {
1717
return callExpression.callee.type === 'Identifier' && callExpression.callee.name === 'i18nString';
1818
}
1919

20+
/**
21+
* @type {import('eslint').Rule.RuleModule}
22+
*/
2023
module.exports = {
2124
meta: {
2225
type: 'problem',

scripts/eslint_rules/lib/l10n-no-locked-or-placeholder-only-phrase.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const l10nHelper = require('./l10n-helper.js');
99
const FULLY_LOCKED_PHRASE_REGEX = /^`[^`]*`$/;
1010
const SINGLE_PLACEHOLDER_REGEX = /^\{\w+\}$/; // Matches the PH regex in `collect-strings.js`.
1111

12+
/**
13+
* @type {import('eslint').Rule.RuleModule}
14+
*/
1215
module.exports = {
1316
meta: {
1417
type: 'problem',

scripts/eslint_rules/lib/l10n-no-uistrings-export.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const l10nHelper = require('./l10n-helper.js');
88

99
const MODULE_UI_STRINGS_FILENAME_REGEX = /ModuleUIStrings\.(js|ts)$/;
1010

11+
/**
12+
* @type {import('eslint').Rule.RuleModule}
13+
*/
1114
module.exports = {
1215
meta: {
1316
type: 'problem',

scripts/eslint_rules/lib/l10n-no-unused-message.js

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ function isStandardUIStringsMemberExpression(expr) {
1919
return expr.property.type === 'Identifier';
2020
}
2121

22+
/**
23+
* @type {import('eslint').Rule.RuleModule}
24+
*/
2225
module.exports = {
2326
meta: {
2427
type: 'problem',

scripts/eslint_rules/lib/lit-html-host-this.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
const {isLitHtmlRenderCall} = require('./utils.js');
77

8+
/**
9+
* @type {import('eslint').Rule.RuleModule}
10+
*/
811
module.exports = {
912
meta: {
1013
type: 'problem',

scripts/eslint_rules/lib/lit-html-no-attribute-quotes.js

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ function removeQuotesFromAttribute({fixer, firstPart, secondPart}) {
3333
return [fixer.removeRange(startingQuoteRangeToRemove), fixer.removeRange(endingQuoteRangeToRemove)];
3434
}
3535

36+
/**
37+
* @type {import('eslint').Rule.RuleModule}
38+
*/
3639
module.exports = {
3740
meta: {
3841
type: 'problem',

scripts/eslint_rules/lib/lit-template-result-or-nothing.js

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// found in the LICENSE file.
44
'use strict';
55

6+
/**
7+
* @type {import('eslint').Rule.RuleModule}
8+
*/
69
module.exports = {
710
meta: {
811
type: 'problem',

scripts/eslint_rules/lib/no-a-tags-in-lit-html.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
const {isLitHtmlTemplateCall} = require('./utils.js');
77

8+
/**
9+
* @type {import('eslint').Rule.RuleModule}
10+
*/
811
module.exports = {
912
meta: {
1013
type: 'problem',

scripts/eslint_rules/lib/no-assert-equal.js

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// Rule Definition
1313
// ------------------------------------------------------------------------------
1414

15+
/**
16+
* @type {import('eslint').Rule.RuleModule}
17+
*/
1518
module.exports = {
1619
meta: {
1720
type: 'problem',

scripts/eslint_rules/lib/no-assert-strict-equal-for-arrays-and-objects.js

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// Rule Definition
1313
// ------------------------------------------------------------------------------
1414

15+
/**
16+
* @type {import('eslint').Rule.RuleModule}
17+
*/
1518
module.exports = {
1619
meta: {
1720
type: 'problem',

0 commit comments

Comments
 (0)