Skip to content

Commit

Permalink
Update EsLint v9
Browse files Browse the repository at this point in the history
Bug: none
Change-Id: Iebcc53c0f70a51242f22e4df167cd588b08cefcd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6140633
Reviewed-by: Benedikt Meurer <[email protected]>
Commit-Queue: Nikolay Vitkov <[email protected]>
Auto-Submit: Nikolay Vitkov <[email protected]>
  • Loading branch information
Lightning00Blade authored and Devtools-frontend LUCI CQ committed Jan 7, 2025
1 parent 9307c37 commit b4e8dc7
Show file tree
Hide file tree
Showing 6,543 changed files with 177,981 additions and 174,932 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
73 changes: 28 additions & 45 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import importPlugin from 'eslint-plugin-import';
import jsdocPlugin from 'eslint-plugin-jsdoc';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import stylisticPlugin from '@stylistic/eslint-plugin';
import { join } from 'path';

rulesdirPlugin.RULES_DIR = join(
Expand Down Expand Up @@ -58,27 +59,27 @@ export default [
],
},
{
name: 'JavaScript files',
plugins: {
'@typescript-eslint': typescriptPlugin,
'@stylistic': stylisticPlugin,
mocha: mochaPlugin,
rulesdir: rulesdirPlugin,
import: importPlugin,
jsdoc: jsdocPlugin,
},

languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
},

parser: tsParser,
ecmaVersion: 'latest',
sourceType: 'module',
},

rules: {
// syntax preferences
quotes: [
'@stylistic/quotes': [
'error',
'single',
{
Expand All @@ -87,12 +88,12 @@ export default [
},
],

semi: 'error',
'no-extra-semi': 'error',
'comma-style': ['error', 'last'],
'wrap-iife': ['error', 'inside'],
'@stylistic/semi': 'error',
'@stylistic/no-extra-semi': 'error',
'@stylistic/comma-style': ['error', 'last'],
'@stylistic/wrap-iife': ['error', 'inside'],

'spaced-comment': [
'@stylistic/spaced-comment': [
'error',
'always',
{
Expand All @@ -111,10 +112,10 @@ export default [
],

curly: 'error',
'new-parens': 'error',
'func-call-spacing': 'error',
'arrow-parens': ['error', 'as-needed'],
'eol-last': 'error',
'@stylistic/new-parens': 'error',
'@stylistic/func-call-spacing': 'error',
'@stylistic/arrow-parens': ['error', 'as-needed'],
'@stylistic/eol-last': 'error',
'object-shorthand': ['error', 'properties'],
'no-useless-rename': 'error',

Expand Down Expand Up @@ -154,7 +155,7 @@ export default [
'no-implied-eval': 'error',
'no-labels': 'error',
'no-multi-str': 'error',
'no-new-object': 'error',
'no-object-constructor': 'error',
'no-octal-escape': 'error',
'no-self-compare': 'error',
'no-shadow-restricted-names': 'error',
Expand All @@ -179,23 +180,23 @@ export default [

// es2015 features
'require-yield': 'error',
'template-curly-spacing': ['error', 'never'],
'@stylistic/template-curly-spacing': ['error', 'never'],

// file whitespace
'no-multiple-empty-lines': [
'@stylistic/no-multiple-empty-lines': [
'error',
{
max: 1,
},
],
'no-mixed-spaces-and-tabs': 'error',
'no-trailing-spaces': 'error',
'linebreak-style': ['error', 'unix'],
'@stylistic/no-mixed-spaces-and-tabs': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/linebreak-style': ['error', 'unix'],

/**
* Disabled, aspirational rules
*/
indent: [
'@stylistic/indent': [
'off',
2,
{
Expand All @@ -208,7 +209,7 @@ export default [
],

// brace-style is disabled, as eslint cannot enforce 1tbs as default, but allman for functions
'brace-style': [
'@stylistic/brace-style': [
'off',
'allman',
{
Expand All @@ -217,7 +218,7 @@ export default [
],

// key-spacing is disabled, as some objects use value-aligned spacing, some not.
'key-spacing': [
'@stylistic/key-spacing': [
'off',
{
beforeColon: false,
Expand All @@ -226,7 +227,7 @@ export default [
},
],

'quote-props': ['error', 'as-needed'],
'@stylistic/quote-props': ['error', 'as-needed'],

// no-implicit-globals will prevent accidental globals
'no-implicit-globals': 'off',
Expand Down Expand Up @@ -263,6 +264,7 @@ export default [
ecmaVersion: 'latest',
sourceType: 'module',

parser: tsParser,
parserOptions: {
allowAutomaticSingleRunInference: true,
project: join(
Expand Down Expand Up @@ -302,9 +304,6 @@ export default [
},
],

'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],

// run just the TypeScript unused-vars rule, else we get duplicate errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
Expand All @@ -314,11 +313,7 @@ export default [
},
],

// run just the TypeScript semi rule, else we get duplicate errors
semi: 'off',
'@typescript-eslint/semi': 'error',

'@typescript-eslint/member-delimiter-style': [
'@stylistic/member-delimiter-style': [
'error',
{
multiline: {
Expand Down Expand Up @@ -366,9 +361,6 @@ export default [
},
],

// func-call-spacing doesn't work well with .ts
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': 'error',
/**
* Enforce that enum members are explicitly defined:
* const enum Foo { A = 'a' } rather than const enum Foo { A }
Expand Down Expand Up @@ -481,15 +473,13 @@ export default [
],
},
},

{
name: 'Scripts files',
files: ['scripts/**/*'],
rules: {
'no-console': 'off',
},
},

{
name: 'Front-end files',
files: ['front_end/**/*'],
Expand All @@ -508,7 +498,6 @@ export default [
'rulesdir/l10n-no-unused-message': 'error',
},
},

{
name: 'Front-end TypeScript files',
files: ['front_end/**/*.ts'],
Expand Down Expand Up @@ -542,7 +531,6 @@ export default [
'rulesdir/jslog-context-list': 'error',
},
},

{
name: 'Front-end meta files',
files: ['front_end/**/*-meta.ts'],
Expand All @@ -557,7 +545,6 @@ export default [
],
},
},

{
name: 'TypeScript test files',
files: [
Expand Down Expand Up @@ -630,7 +617,6 @@ export default [
],
},
},

{
files: [
'front_end/panels/**/components/*.ts',
Expand All @@ -642,7 +628,6 @@ export default [
'rulesdir/prefer-private-class-members': 'error',
},
},

{
files: [
'front_end/panels/recorder/**/*.ts',
Expand All @@ -654,22 +639,19 @@ export default [
'rulesdir/prefer-private-class-members': 'off',
},
},

{
files: ['front_end/generated/SupportedCSSProperties.js'],
rules: {
'rulesdir/jslog-context-list': 'error',
},
},

{
name: 'EsLint rules test',
files: ['scripts/eslint_rules/test/**/*.js'],
rules: {
'rulesdir/no-only-eslint-tests': 'error',
},
},

{
name: 'Legacy test runner',
files: ['front_end/legacy_test_runner/**/*'],
Expand Down Expand Up @@ -712,6 +694,7 @@ export default [
},
},
{
name: 'Performance panel file',
files: ['front_end/ui/legacy/components/perf_ui/**/*.ts'],
rules: {
// Enable tracking of canvas save() and
Expand Down
1 change: 0 additions & 1 deletion front_end/Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* eslint-disable indent */

/**
* @fileoverview This file contains small testing framework along with the
Expand Down
2 changes: 1 addition & 1 deletion front_end/core/common/ParsedURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function normalizePath(path: string): string {
export function schemeIs(url: Platform.DevToolsPath.UrlString, scheme: string): boolean {
try {
return (new URL(url)).protocol === scheme;
} catch (e) {
} catch {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion front_end/core/common/ResolverBase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('ResolverBase', () => {
resolver.assertIsNotListening();
try {
await obj;
} catch (e) {
} catch {
return;
}
assert.fail('Expected `await obj` to throw.');
Expand Down
2 changes: 1 addition & 1 deletion front_end/core/common/SettingRegistration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('SettingRegistration', () => {
assert.strictEqual(
preRegisteredSetting.category(), settingCategory, 'Setting category is not returned correctly');
assert.isNotTrue(preRegisteredSetting.get(), 'Setting value is not returned correctly');
} catch (error) {
} catch {
assert.fail('Failed to find setting registration');
}
});
Expand Down
6 changes: 3 additions & 3 deletions front_end/core/common/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class Setting<V> {
if (this.storage.has(this.name)) {
try {
this.#value = this.#serializer.parse(this.storage.get(this.name));
} catch (e) {
} catch {
this.storage.remove(this.name);
}
}
Expand All @@ -484,7 +484,7 @@ export class Setting<V> {
if (value) {
try {
this.#value = this.#serializer.parse(value);
} catch (e) {
} catch {
this.storage.remove(this.name);
}
}
Expand Down Expand Up @@ -648,7 +648,7 @@ export class RegExpSetting extends Setting<any> {
if (pattern) {
this.#regex = new RegExp(pattern, this.#regexFlags || '');
}
} catch (e) {
} catch {
}
return this.#regex;
}
Expand Down
2 changes: 1 addition & 1 deletion front_end/core/host/InspectorFrontendHostAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,5 +487,5 @@ export const enum EnumeratedHistogram {
SwatchActivated = 'DevTools.SwatchActivated',
AnimationPlaybackRateChanged = 'DevTools.AnimationPlaybackRateChanged',
AnimationPointDragged = 'DevTools.AnimationPointDragged',
/* eslint-disable @typescript-eslint/naming-convention -- Shadows a legacy enum */

}
2 changes: 1 addition & 1 deletion front_end/core/host/ResourceLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function canBeRemoteFilePath(url: string): boolean {
try {
const urlObject = new URL(url);
return urlObject.protocol === 'file:' && urlObject.host !== '';
} catch (exception) {
} catch {
return false;
}
}
Expand Down
Loading

0 comments on commit b4e8dc7

Please sign in to comment.