Files
react-native-devtools-frontend/scripts/eslint_rules/lib/custom_element_component_definition.js
T
Kriti Sapra 2597b415c1 Added linting rule to use helper function to define component
Bug: 1205825
Change-Id: I78ce8199dc599be1f1121e65b72b83a8f73733c4
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2878729
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-05-07 13:09:29 +00:00

40 lines
1.1 KiB
JavaScript

// Copyright 2021 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.
'use strict';
/**
* @fileoverview Prevent usage of customElements.define() and use the helper
* function instead
*/
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Usage of customElements.define',
category: 'Possible Errors',
},
fixable: 'code',
schema: [] // no options
},
create: function(context) {
return {
MemberExpression(node) {
if (node.object.name === 'customElements' && node.property.name === 'define') {
context.report({
node,
message:
'do not use customElements.define() to define a component. Use the CustomElements.defineComponent() function in front_end/ui/components/helper instead.'
});
}
}
};
}
};