eslint plugin files rename from ts to tsx
Summary: mass rename files Reviewed By: nikoant Differential Revision: D33890201 fbshipit-source-id: ac73fb040519a566447981bad37b8c78878a5c3d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a474a0c2f2
commit
2476472344
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {TSESTree} from '@typescript-eslint/experimental-utils';
|
||||
import {createESLintRule} from '../utils/createEslintRule';
|
||||
|
||||
type Options = [];
|
||||
|
||||
export type MessageIds = 'noElectronRemoteImports';
|
||||
export const RULE_NAME = 'no-electron-remote-imports';
|
||||
|
||||
export default createESLintRule<Options, MessageIds>({
|
||||
name: RULE_NAME,
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
docs: {
|
||||
description: '`remote` is slow. Please be careful when using it.',
|
||||
recommended: 'warn',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
noElectronRemoteImports:
|
||||
'Accessing properties on the `remote` object is blocking and 10,000x slower than a local one. Please consider alternatives or cache your access.',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
return {
|
||||
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
||||
if (node.source.value === 'electron') {
|
||||
const hasImport =
|
||||
node.specifiers.filter(
|
||||
(v) =>
|
||||
v.type === 'ImportSpecifier' && v.imported.name === 'remote',
|
||||
).length > 0;
|
||||
if (hasImport) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noElectronRemoteImports',
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user