casing convension
Summary: [eslint-typescript/naming-convension rule docs](https://typescript-eslint.io/rules/naming-convention/) Initially looked into it to enforce UPPER_CASE for top most constants like `const DELAY = 10` which is a standard in js ecosystem, which turned to be more difficuilt(we will still get there). Turns out we had casing checks disabled for everything but typeLike names. What I did in this diff - use default setting for eslint rule `✖ 9890 problems` - with any propery names `✖ 8229 problems` - without checking properies at all `✖ 3683 problems` - without checking enum members `✖ 3231 problems` - without checking object properties/methods `✖ 2978 problems` - allowing PascalCase for variables `✖ 1657 problems - allowing PascalCase for functions `✖ 975 problems - not checking typeMethod and parameters `✖ 916 problems` - allow double underscore before after variable `✖ 461 problems` - allow snake_case variables `✖ 49 problems` Fix remaining problems. Future plans. Ban usage of PascalCase for variables that are not components Reviewed By: LukeDefeo Differential Revision: D50970193 fbshipit-source-id: d9f3abe6b02c9f7822598c8fa5382f58d067f70e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3bb3ce6a66
commit
99dbcfa079
@@ -214,11 +214,35 @@ module.exports = {
|
||||
],
|
||||
'@typescript-eslint/naming-convention': [
|
||||
2,
|
||||
{
|
||||
selector: 'default',
|
||||
format: ['camelCase'],
|
||||
leadingUnderscore: 'allow',
|
||||
trailingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
selector: 'variable',
|
||||
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
trailingUnderscore: 'allowSingleOrDouble',
|
||||
},
|
||||
{
|
||||
selector: 'function',
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
leadingUnderscore: 'allow',
|
||||
trailingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
selector: 'typeLike',
|
||||
format: ['PascalCase', 'UPPER_CASE'],
|
||||
leadingUnderscore: 'allow',
|
||||
},
|
||||
{
|
||||
selector: ['property', 'method', 'memberLike', 'parameter'],
|
||||
// do not enforce naming convention for properties
|
||||
// no support for kebab-case
|
||||
format: null,
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||||
},
|
||||
|
||||
@@ -57,7 +57,7 @@ export function plugin(client: PluginClient<Events, Methods>) {
|
||||
});
|
||||
});
|
||||
|
||||
function _unused_JustTypeChecks() {
|
||||
function _unusedJustTypeChecks() {
|
||||
// @ts-expect-error Argument of type '"bla"' is not assignable
|
||||
client.send('bla', {});
|
||||
// @ts-expect-error Argument of type '{ stuff: string; }' is not assignable to parameter of type
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export const unstable_batchedUpdates = (cb: () => void) => {
|
||||
return cb();
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ export function plugin(client: PluginClient<Events, Methods>) {
|
||||
});
|
||||
});
|
||||
|
||||
function _unused_JustTypeChecks() {
|
||||
function _unusedJustTypeChecks() {
|
||||
// @ts-expect-error Argument of type '"bla"' is not assignable
|
||||
client.send('bla', {});
|
||||
// @ts-expect-error Argument of type '{ stuff: string; }' is not assignable to parameter of type
|
||||
|
||||
@@ -120,6 +120,7 @@ export default class Orderable extends React.Component<
|
||||
return !this.state.movingOrder;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
UNSAFE_componentWillReceiveProps(nextProps: OrderableProps) {
|
||||
this.setState({
|
||||
order: nextProps.order,
|
||||
|
||||
@@ -120,6 +120,7 @@ class SearchableManagedTable extends PureComponent<Props, State> {
|
||||
this.props.defaultFilters.map(this.props.addFilter);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
||||
if (
|
||||
nextProps.searchTerm !== this.props.searchTerm ||
|
||||
|
||||
@@ -229,6 +229,7 @@ export class ManagedTable extends React.Component<
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
UNSAFE_componentWillReceiveProps(nextProps: ManagedTableProps) {
|
||||
// if columnSizes has changed
|
||||
if (nextProps.columnSizes !== this.props.columnSizes) {
|
||||
|
||||
Reference in New Issue
Block a user