-
Notifications
You must be signed in to change notification settings - Fork 498
/
Copy pathno-new-lit-element-components.ts
45 lines (42 loc) · 1.26 KB
/
no-new-lit-element-components.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2023 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {createRule} from './utils/ruleCreator.ts';
const allowedPaths = [
'front_end/panels/recorder/',
'front_end/ui/components/suggestion_input/',
];
export default createRule({
name: 'no-new-lit-element-components',
meta: {
type: 'problem',
docs: {
description: 'Check that no new LitElement components are introduced',
category: 'Possible Errors',
},
messages: {
noNewLitElementComponents: 'New LitElement components are banned.',
},
schema: [] // no options
},
defaultOptions: [],
create: function(context) {
const filename = context.filename ?? context.getFilename();
return {
ClassDeclaration(node) {
// Use `extends LitElement` as a signal.
if (node.superClass?.type !== 'Identifier' || node.superClass?.name !== 'LitElement') {
return;
}
// Existing components are still allowed.
if (allowedPaths.some(path => filename.startsWith(path))) {
return;
}
context.report({
node,
messageId: 'noNewLitElementComponents',
});
},
};
}
});