diff --git a/desktop/.eslintrc.js b/desktop/.eslintrc.js index c66b79852..bf176de6d 100644 --- a/desktop/.eslintrc.js +++ b/desktop/.eslintrc.js @@ -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', }, diff --git a/desktop/flipper-plugin/src/__tests__/TestPlugin.tsx b/desktop/flipper-plugin/src/__tests__/TestPlugin.tsx index 17705ab4e..5465cc6f9 100644 --- a/desktop/flipper-plugin/src/__tests__/TestPlugin.tsx +++ b/desktop/flipper-plugin/src/__tests__/TestPlugin.tsx @@ -57,7 +57,7 @@ export function plugin(client: PluginClient) { }); }); - 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 diff --git a/desktop/flipper-server-companion/src/globalsReplacements/fakeReactDOM.tsx b/desktop/flipper-server-companion/src/globalsReplacements/fakeReactDOM.tsx index cf6fbc190..b7c372de3 100644 --- a/desktop/flipper-server-companion/src/globalsReplacements/fakeReactDOM.tsx +++ b/desktop/flipper-server-companion/src/globalsReplacements/fakeReactDOM.tsx @@ -7,6 +7,7 @@ * @format */ +// eslint-disable-next-line @typescript-eslint/naming-convention export const unstable_batchedUpdates = (cb: () => void) => { return cb(); }; diff --git a/desktop/flipper-ui-core/src/__tests__/test-utils/TestPlugin.tsx b/desktop/flipper-ui-core/src/__tests__/test-utils/TestPlugin.tsx index ed3a8a4ca..279d96de5 100644 --- a/desktop/flipper-ui-core/src/__tests__/test-utils/TestPlugin.tsx +++ b/desktop/flipper-ui-core/src/__tests__/test-utils/TestPlugin.tsx @@ -52,7 +52,7 @@ export function plugin(client: PluginClient) { }); }); - 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 diff --git a/desktop/flipper-ui-core/src/ui/components/Orderable.tsx b/desktop/flipper-ui-core/src/ui/components/Orderable.tsx index d639ff095..2210a7e07 100644 --- a/desktop/flipper-ui-core/src/ui/components/Orderable.tsx +++ b/desktop/flipper-ui-core/src/ui/components/Orderable.tsx @@ -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, diff --git a/desktop/flipper-ui-core/src/ui/components/searchable/SearchableTable.tsx b/desktop/flipper-ui-core/src/ui/components/searchable/SearchableTable.tsx index d3df581bd..7718b45c6 100644 --- a/desktop/flipper-ui-core/src/ui/components/searchable/SearchableTable.tsx +++ b/desktop/flipper-ui-core/src/ui/components/searchable/SearchableTable.tsx @@ -120,6 +120,7 @@ class SearchableManagedTable extends PureComponent { 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 || diff --git a/desktop/flipper-ui-core/src/ui/components/table/ManagedTable.tsx b/desktop/flipper-ui-core/src/ui/components/table/ManagedTable.tsx index f9c3919af..b40b075ec 100644 --- a/desktop/flipper-ui-core/src/ui/components/table/ManagedTable.tsx +++ b/desktop/flipper-ui-core/src/ui/components/table/ManagedTable.tsx @@ -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) {