rename left ts files to tsx and ban ts file extension
Summary: mass files rename Reviewed By: passy Differential Revision: D33890304 fbshipit-source-id: c057ac9fe87dd7659597c85d640619b93e1ff0e6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e98b34a407
commit
05a3bb69dc
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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 {createESLintRule} from '../utils/createEslintRule';
|
||||
|
||||
type Options = [];
|
||||
|
||||
export type MessageIds = 'noTsInterfacePrefixI';
|
||||
export const RULE_NAME = 'no-i-prefix-interfaces';
|
||||
|
||||
export default createESLintRule<Options, MessageIds>({
|
||||
name: RULE_NAME,
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Avoid prefixing TS interfaces with "I"',
|
||||
recommended: 'error',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
noTsInterfacePrefixI: 'Do not prefix interfaces with "I"',
|
||||
},
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
return {
|
||||
TSInterfaceDeclaration(node) {
|
||||
const [l1, l2, l3] = node.id.name;
|
||||
if (
|
||||
l1 === 'I' &&
|
||||
isLetter(l2) &&
|
||||
l2 === l2.toUpperCase() &&
|
||||
isLetter(l3) &&
|
||||
l3 === l3.toLowerCase()
|
||||
) {
|
||||
context.report({
|
||||
node: node.id,
|
||||
messageId: 'noTsInterfacePrefixI',
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
function isLetter(x: string | undefined): boolean {
|
||||
return typeof x === 'string' && /^[a-z]$/i.test(x);
|
||||
}
|
||||
Reference in New Issue
Block a user