Skip to content

Commit e7a43fb

Browse files
committed
Convert no-new-lit-element-components to TypeScript
Bug: chromium:397586315 Change-Id: I5c7e6e8714c36259ffd8fbefd11d65656d7bc4c3 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6438837 Auto-Submit: Mathias Bynens <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]> Reviewed-by: Nikolay Vitkov <[email protected]>
1 parent c1bd58c commit e7a43fb

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
// Copyright 2023 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
'use strict';
4+
5+
import {createRule} from './tsUtils.ts';
56

67
const allowedPaths = [
78
'front_end/panels/recorder/',
89
'front_end/ui/components/suggestion_input/',
910
];
10-
/**
11-
* @type {import('eslint').Rule.RuleModule}
12-
*/
13-
module.exports = {
11+
12+
export default createRule({
13+
name: 'no-new-lit-element-components',
1414
meta: {
1515
type: 'problem',
1616
docs: {
1717
description: 'Check that no new LitElement components are introduced',
1818
category: 'Possible Errors',
1919
},
20+
messages: {
21+
noNewLitElementComponents: 'New LitElement components are banned.',
22+
},
2023
schema: [] // no options
2124
},
25+
defaultOptions: [],
2226
create: function(context) {
2327
const filename = context.filename ?? context.getFilename();
2428
return {
@@ -33,10 +37,9 @@ module.exports = {
3337
}
3438
context.report({
3539
node,
36-
message:
37-
'New LitElement components are banned.',
40+
messageId: 'noNewLitElementComponents',
3841
});
3942
},
4043
};
4144
}
42-
};
45+
});

scripts/eslint_rules/tests/no-new-lit-element-components.test.js renamed to scripts/eslint_rules/tests/no-new-lit-element-components.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Copyright 2023 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
'use strict';
5-
const rule = require('../lib/no-new-lit-element-components.js');
64

7-
const {RuleTester} = require('./utils/utils.js');
5+
import rule from '../lib/no-new-lit-element-components.ts';
86

9-
const EXPECTED_ERROR_MESSAGE = 'New LitElement components are banned.';
7+
import {RuleTester} from './utils/tsUtils.ts';
108

119
new RuleTester().run('no-new-lit-element-components', rule, {
1210
valid: [
@@ -23,7 +21,7 @@ new RuleTester().run('no-new-lit-element-components', rule, {
2321
{
2422
code: 'class A extends LitElement {}',
2523
filename: 'front_end/components/test.ts',
26-
errors: [{message: EXPECTED_ERROR_MESSAGE}],
24+
errors: [{messageId: 'noNewLitElementComponents'}],
2725
},
2826
],
2927
});

0 commit comments

Comments
 (0)