-
Notifications
You must be signed in to change notification settings - Fork 498
/
Copy pathno-adopted-style-sheets.ts
37 lines (33 loc) · 1.02 KB
/
no-adopted-style-sheets.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
// Copyright 2025 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.
/**
* @fileoverview Rule to ban usage of `adoptedStyleSheets`.
* @author Benedikt Meurer
* @see https://web.dev/articles/constructable-stylesheets
*/
import {createRule} from './utils/ruleCreator.ts';
export default createRule({
name: 'no-adopted-style-sheets',
meta: {
type: 'problem',
docs: {
description: 'Disallow usage of adoptedStyleSheets',
category: 'Possible Errors',
},
messages: {
noAdoptedStyleSheetsProperty: 'The adoptedStyleSheets property is banned, use <style> elements instead.',
},
schema: [], // no options
},
defaultOptions: [],
create(context) {
return {
MemberExpression(node) {
if (node.property.type === 'Identifier' && node.property.name === 'adoptedStyleSheets') {
context.report({node, messageId: 'noAdoptedStyleSheetsProperty'});
}
},
};
},
});