blob: 9fd40fdcede9b82fefaec35d99e92350b30ee9a2 [file] [log] [blame]
Tim van der Lippe33543ac2020-12-14 14:37:451// Copyright 2020 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
Ergün Erdoğmuş5f638ba2022-05-05 09:30:215// clang-format off
Tim van der Lippe406249f2020-12-14 14:59:106const path = require('path');
7const rulesDirPlugin = require('eslint-plugin-rulesdir');
8rulesDirPlugin.RULES_DIR = path.join(__dirname, '..', 'scripts', 'eslint_rules', 'lib');
9
Tim van der Lippe33543ac2020-12-14 14:37:4510module.exports = {
Jack Franklin2d72d762024-09-23 11:05:0511 rules: {
Simon Zündf6afbca2021-03-02 06:11:1412 // L10n rules are only relevant in 'front_end'.
Jack Franklin18c71912021-12-01 14:58:0013 'rulesdir/l10n_filename_matches': [
Nikolay Vitkovc62f5c52024-01-17 13:23:3414 'error', {
Jack Franklin18c71912021-12-01 14:58:0015 rootFrontendDirectory: __dirname,
16 }
17 ],
Nikolay Vitkovc62f5c52024-01-17 13:23:3418 'rulesdir/l10n_i18nString_call_only_with_uistrings': 'error',
19 'rulesdir/l10n_no_i18nString_calls_module_instantiation': 'error',
20 'rulesdir/l10n_no_locked_or_placeholder_only_phrase': 'error',
21 'rulesdir/l10n_no_uistrings_export': 'error',
22 'rulesdir/l10n_no_unused_message': 'error',
Simon Zündf6afbca2021-03-02 06:11:1423 },
Jack Franklin2d72d762024-09-23 11:05:0524 overrides: [
Sigurd Schneiderc8702c92021-02-12 10:10:0525 {
Jack Franklin2d72d762024-09-23 11:05:0526 files: ['*.ts'],
27 rules: {
Danil Somsikovacd635c2024-02-09 12:56:5128 '@typescript-eslint/explicit-function-return-type': [
29 'error', {
Jack Franklin2d72d762024-09-23 11:05:0530 allowExpressions: true,
31 allowConciseArrowFunctionExpressionsStartingWithVoid: true,
32 allowIIFEs:true,
Danil Somsikovacd635c2024-02-09 12:56:5133 },
34 ],
Nikolay Vitkovc62f5c52024-01-17 13:23:3435 'rulesdir/no_importing_images_from_src': 'error',
36 'rulesdir/enforce_bound_render_for_schedule_render': 'error',
37 'rulesdir/enforce_custom_event_names': 'error',
38 'rulesdir/set_data_type_reference': 'error',
39 'rulesdir/no_bound_component_methods': 'error',
Nikolay Vitkovc62f5c52024-01-17 13:23:3440 'rulesdir/lit_no_style_interpolation': 'error',
Nikolay Vitkovc62f5c52024-01-17 13:23:3441 'rulesdir/ban_self_closing_custom_element_tagnames': 'error',
42 'rulesdir/ban_style_tags_in_lit_html': 'error',
43 'rulesdir/ban_a_tags_in_lit_html': 'error',
Nikolay Vitkovc62f5c52024-01-17 13:23:3444 'rulesdir/check_css_import': 'error',
Paul Irishfa68c092024-07-12 21:24:0745 'rulesdir/enforce-optional-properties-last': 'error',
Nikolay Vitkovc62f5c52024-01-17 13:23:3446 'rulesdir/check_enumerated_histograms': 'error',
47 'rulesdir/check_was_shown_methods': 'error',
48 'rulesdir/static_custom_event_names': 'error',
49 'rulesdir/lit_html_host_this': 'error',
50 'rulesdir/lit_html_no_attribute_quotes': 'error',
51 'rulesdir/lit_template_result_or_nothing': 'error',
52 'rulesdir/inject_checkbox_styles': 'error',
Danil Somsikov08ac9732024-08-06 19:45:0753 'rulesdir/jslog_context_list': 'error',
Sigurd Schneiderc8702c92021-02-12 10:10:0554 }
55 },
56 {
Jack Franklin2d72d762024-09-23 11:05:0557 files: ['*-meta.ts'],
58 rules: {
Sigurd Schneiderc8702c92021-02-12 10:10:0559 '@typescript-eslint/naming-convention': [
60 'error', {
Jack Franklin2d72d762024-09-23 11:05:0561 selector: 'parameter',
62 format: ['camelCase', 'PascalCase'],
63 leadingUnderscore: 'allow',
Sigurd Schneiderc8702c92021-02-12 10:10:0564 }
65 ]
66 }
Tim van der Lippedb15a5f2021-12-15 14:33:2767 },
68 {
Jack Franklin2d72d762024-09-23 11:05:0569 files: ['*.test.ts', '**/testing/*.ts'],
70 rules: {
Benedikt Meurer82744072024-02-20 07:52:3771 '@typescript-eslint/explicit-function-return-type': 'off',
Benedikt Meurer82744072024-02-20 07:52:3772 },
73 },
74 {
Jack Franklin2d72d762024-09-23 11:05:0575 files: ['panels/**/components/*.ts', 'ui/components/**/*.ts', 'entrypoints/**/*.ts'],
76 rules: {
Nikolay Vitkovc62f5c52024-01-17 13:23:3477 'rulesdir/use_private_class_members': 'error',
Tim van der Lippedb15a5f2021-12-15 14:33:2778 }
Alex Rudenko128c7b32023-05-03 11:03:4379 },
80 // TODO(crbug/1402569): Remove once LitElement is fully adopted.
81 {
Jack Franklin2d72d762024-09-23 11:05:0582 files: ['panels/recorder/**/*.ts', 'panels/protocol_monitor/**/*.ts', 'ui/components/suggestion_input/*.ts'],
83 rules: {
Alex Rudenko128c7b32023-05-03 11:03:4384 // TODO(crbug/1402569): Reenable once https://github.com/microsoft/TypeScript/issues/48885 is closed.
Nikolay Vitkovc62f5c52024-01-17 13:23:3485 'rulesdir/use_private_class_members': 'off',
Alex Rudenko128c7b32023-05-03 11:03:4386 }
Danil Somsikov1a6d02a2024-08-27 15:21:0187 },
88 {
Jack Franklin2d72d762024-09-23 11:05:0589 files: ['generated/SupportedCSSProperties.js'],
90 rules: {
Danil Somsikov1a6d02a2024-08-27 15:21:0191 'rulesdir/jslog_context_list': 'error',
92 }
Tim van der Lippe33543ac2020-12-14 14:37:4593 }
Sigurd Schneiderc8702c92021-02-12 10:10:0594 ]
Tim van der Lippe33543ac2020-12-14 14:37:4595};
Ergün Erdoğmuş5f638ba2022-05-05 09:30:2196// clang-format on