blob: 689eba27292a3d3110266d0c800ce740f079e239 [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
Tim van der Lippe406249f2020-12-14 14:59:105const path = require('path');
6const rulesDirPlugin = require('eslint-plugin-rulesdir');
7rulesDirPlugin.RULES_DIR = path.join(__dirname, '..', 'scripts', 'eslint_rules', 'lib');
8
Tim van der Lippe33543ac2020-12-14 14:37:459module.exports = {
Sigurd Schneiderc8702c92021-02-12 10:10:0510 'overrides': [
11 {
12 'files': ['*.ts'],
13 'rules': {
14 '@typescript-eslint/explicit-function-return-type': 2,
Tim van der Lippe406249f2020-12-14 14:59:1015
Sigurd Schneiderc8702c92021-02-12 10:10:0516 'rulesdir/kebab_case_events': 2,
17 'rulesdir/set_data_type_reference': 2,
18 'rulesdir/lit_html_data_as_type': 2,
19 'rulesdir/lit_no_style_interpolation': 2,
20 '@typescript-eslint/naming-convention': [
21 'error', {
Sigurd Schneider17c74452021-02-15 12:14:1022 'selector': ['property', 'parameterProperty'],
Sigurd Schneiderc8702c92021-02-12 10:10:0523 'format': ['camelCase'],
24 },
25 {
Sigurd Schneidercb2d4562021-02-15 08:56:1826 'selector': 'property',
27 'modifiers': ['public'],
28 'format': ['camelCase'],
29 'leadingUnderscore': 'allow',
30 },
31 {
32 'selector': 'classProperty',
33 'modifiers': ['static', 'readonly'],
34 'format': ['UPPER_CASE'],
35 },
36 {
Sigurd Schneiderc8702c92021-02-12 10:10:0537 'selector': 'method',
Sigurd Schneiderc8702c92021-02-12 10:10:0538 'format': ['camelCase'],
39 },
40 {
Sigurd Schneider91147d82021-02-15 11:00:0841 'selector': 'function',
42 'format': ['camelCase'],
43 },
44 {
Sigurd Schneider17c74452021-02-15 12:14:1045 'selector': 'variable',
46 'filter': {
47 // Ignore localization variables.
48 'regex': '^(UIStrings|str_)$',
49 'match': false
50 },
51 'format': ['camelCase'],
52 },
53 {
54 // We are using camelCase, PascalCase and UPPER_CASE for top-level constants, allow the for now.
55 'selector': 'variable',
56 'modifiers': ['const'],
57 'filter': {
58 // Ignore localization variables.
59 'regex': '^(UIStrings|str_)$',
60 'match': false
61 },
62 'format': ['camelCase', 'UPPER_CASE', 'PascalCase'],
63 },
64 {
Sigurd Schneider6c774ca2021-02-15 08:09:1465 // Public methods are currently in transition and may still have leading underscores.
66 'selector': 'method',
67 'modifiers': ['public'],
68 'format': ['camelCase'],
69 'leadingUnderscore': 'allow',
70 },
71 {
72 // Object literals may be constructed as arguments to external libraries which follow different styles.
73 'selector': ['objectLiteralMethod', 'objectLiteralProperty'],
74 'modifiers': ['public'],
75 'format': null,
76 },
77 {
Sigurd Schneiderc8702c92021-02-12 10:10:0578 'selector': 'accessor',
79 'format': ['camelCase'],
80 },
81 {
Sigurd Schneideraf302d02021-02-15 09:45:3582 'selector': 'enumMember',
83 'format': ['PascalCase', 'UPPER_CASE'],
84 },
85 {
Sigurd Schneider6c774ca2021-02-15 08:09:1486 'selector': ['typeLike'],
Sigurd Schneiderc8702c92021-02-12 10:10:0587 'format': ['PascalCase'],
88 },
89 {
90 'selector': 'parameter',
91 'format': ['camelCase'],
92 'leadingUnderscore': 'allow',
93 }
94 ]
95 }
96 },
97 {
98 'files': ['*-meta.ts'],
99 'rules': {
100 '@typescript-eslint/naming-convention': [
101 'error', {
102 'selector': 'parameter',
103 'format': ['camelCase', 'PascalCase'],
104 'leadingUnderscore': 'allow',
105 }
106 ]
107 }
Tim van der Lippe33543ac2020-12-14 14:37:45108 }
Sigurd Schneiderc8702c92021-02-12 10:10:05109 ]
Tim van der Lippe33543ac2020-12-14 14:37:45110};