Skip to content

Commit 65c9959

Browse files
authored
Error for all recommend ESLint rules (#20117)
Signed-off-by: Josh Gross <git@joshmgross.com>
1 parent c08871e commit 65c9959

15 files changed

Lines changed: 43 additions & 41 deletions

File tree

web/vtadmin/eslint.config.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* limitations under the License.
1515
*/
1616
import js from '@eslint/js';
17+
import { defineConfig } from 'eslint/config'
1718
import tseslint from 'typescript-eslint';
1819
import react from 'eslint-plugin-react';
1920
import reactHooks from 'eslint-plugin-react-hooks';
2021
import jsxA11y from 'eslint-plugin-jsx-a11y';
2122
import globals from 'globals';
2223

23-
export default tseslint.config(
24+
export default defineConfig(
2425
{
2526
ignores: ['build/**', 'node_modules/**', 'src/proto/**'],
2627
},
@@ -54,7 +55,7 @@ export default tseslint.config(
5455
},
5556
rules: {
5657
// Carried over from eslint-config-react-app
57-
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none', ignoreRestSiblings: true }],
58+
'@typescript-eslint/no-unused-vars': ['error', { args: 'none', ignoreRestSiblings: true }],
5859
'@typescript-eslint/no-explicit-any': 'off',
5960
'@typescript-eslint/no-empty-object-type': 'off',
6061
'@typescript-eslint/no-unsafe-function-type': 'off',
@@ -73,23 +74,22 @@ export default tseslint.config(
7374
'statusbar', 'stop', 'toolbar', 'top',
7475
],
7576

76-
// Not enabled in eslint-config-react-app; disable to keep migration clean
77-
'prefer-const': 'off',
78-
'no-extra-boolean-cast': 'off',
79-
'no-var': 'off',
80-
'no-case-declarations': 'off',
77+
'prefer-const': 'error',
78+
'no-extra-boolean-cast': 'error',
79+
'no-var': 'error',
80+
'no-case-declarations': 'error',
8181

8282
// React
8383
'react/prop-types': 'off', // TypeScript handles prop validation
8484
'react/display-name': 'off',
85-
'react/jsx-key': 'warn',
86-
'react/jsx-no-target-blank': 'warn',
85+
'react/jsx-key': 'error',
86+
'react/jsx-no-target-blank': 'error',
8787
'react/no-unescaped-entities': 'off',
8888

8989
// Accessibility: match eslint-config-react-app (warn, not error)
90-
'jsx-a11y/no-autofocus': 'warn',
91-
'jsx-a11y/click-events-have-key-events': 'warn',
92-
'jsx-a11y/no-static-element-interactions': 'warn',
90+
'jsx-a11y/no-autofocus': 'error',
91+
'jsx-a11y/click-events-have-key-events': 'error',
92+
'jsx-a11y/no-static-element-interactions': 'error',
9393

9494
// react-hooks plugin v7 added these; not in eslint-config-react-app
9595
'react-hooks/immutability': 'off',

web/vtadmin/src/api/http.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('api/http', () => {
8181
try {
8282
await api.fetchTablets();
8383
} catch (error) {
84-
let e: HttpResponseNotOkError = error as HttpResponseNotOkError;
84+
const e: HttpResponseNotOkError = error as HttpResponseNotOkError;
8585
expect(e.name).toEqual(HTTP_RESPONSE_NOT_OK_ERROR);
8686
expect(e.message).toEqual('[status 500] /api/tablets: oh_no something went wrong');
8787
expect(e.response).toEqual(response);
@@ -107,7 +107,7 @@ describe('api/http', () => {
107107
try {
108108
await api.vtfetch(endpoint);
109109
} catch (error) {
110-
let e: MalformedHttpResponseError = error as MalformedHttpResponseError;
110+
const e: MalformedHttpResponseError = error as MalformedHttpResponseError;
111111
expect(e.name).toEqual(MALFORMED_HTTP_RESPONSE_ERROR);
112112
expect(e.message).toContain(
113113
`[status 504] /api/tablets: Unexpected token '<', "<html><hea"... is not valid JSON`
@@ -127,7 +127,7 @@ describe('api/http', () => {
127127
try {
128128
await api.vtfetch(endpoint);
129129
} catch (error) {
130-
let e: MalformedHttpResponseError = error as MalformedHttpResponseError;
130+
const e: MalformedHttpResponseError = error as MalformedHttpResponseError;
131131
expect(e.name).toEqual(MALFORMED_HTTP_RESPONSE_ERROR);
132132
}
133133
});
@@ -182,7 +182,7 @@ describe('api/http', () => {
182182
try {
183183
await api.vtfetch(endpoint);
184184
} catch (error) {
185-
let e: HttpFetchError = error as HttpFetchError;
185+
const e: HttpFetchError = error as HttpFetchError;
186186
expect(e.message).toEqual(
187187
'Invalid fetch credentials property: nope. Must be undefined or one of omit, same-origin, include'
188188
);
@@ -254,7 +254,7 @@ describe('api/http', () => {
254254
transform: (e) => null, // doesn't matter
255255
});
256256
} catch (error) {
257-
let e: HttpFetchError = error as HttpFetchError;
257+
const e: HttpFetchError = error as HttpFetchError;
258258
expect(e.message).toMatch('expected entities to be an array, got null');
259259

260260
expect(errorHandler.notify).toHaveBeenCalledTimes(1);

web/vtadmin/src/components/pips/ShardServingPip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ interface Props {
2727
}
2828

2929
export const ShardServingPip = ({ isLoading, isServing }: Props) => {
30-
let state: PipState = isServing ? 'success' : 'danger';
30+
const state: PipState = isServing ? 'success' : 'danger';
3131
return <Pip state={isLoading ? null : state} />;
3232
};

web/vtadmin/src/components/placeholders/QueryErrorPlaceholder.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe('QueryErrorPlaceholder', () => {
7171

7272
expect((httpAPI.fetchClusters as any).mock.calls.length).toEqual(1);
7373

74-
let placeholder = await screen.findByRole('status');
75-
let button = within(placeholder).getByRole('button');
74+
const placeholder = await screen.findByRole('status');
75+
const button = within(placeholder).getByRole('button');
7676
expect(button).not.toBeNull();
7777
expect(button.textContent).toEqual('Try again');
7878

web/vtadmin/src/components/routes/Workflows.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,16 @@ export const Workflows = () => {
122122
{/* TODO(doeg): add a protobuf enum for this (https://github.com/vitessio/vitess/projects/12#card-60190340) */}
123123
{['Error', 'Copying', 'Running', 'Stopped'].map((streamState) => {
124124
if (streamState in row.streams) {
125-
var numThrottled = 0;
126-
var throttledApp: string | undefined = '';
125+
let numThrottled = 0;
126+
let throttledApp: string | undefined = '';
127127
const streamCount = row.streams[streamState].length;
128-
var streamDescription: string;
128+
let streamDescription: string;
129129
switch (streamState) {
130130
case 'Error':
131131
streamDescription = 'failed';
132132
break;
133133
case 'Running':
134-
case 'Copying':
134+
case 'Copying': {
135135
const streams = row.streams[streamState];
136136
if (streams !== undefined && streams !== null) {
137137
for (const stream of streams) {
@@ -157,6 +157,7 @@ export const Workflows = () => {
157157
streamState = 'Throttled';
158158
}
159159
break;
160+
}
160161
default:
161162
streamDescription = streamState.toLocaleLowerCase();
162163
}

web/vtadmin/src/components/routes/createKeyspace/CreateKeyspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const CreateKeyspace = () => {
6666
);
6767

6868
let selectedCluster = null;
69-
if (!!formData.clusterID) {
69+
if (formData.clusterID) {
7070
selectedCluster = clusters.find((c) => c.id === formData.clusterID);
7171
}
7272

web/vtadmin/src/components/routes/createSchemaMigration/CreateSchemaMigration.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ export const CreateSchemaMigration = () => {
106106
);
107107

108108
let selectedCluster = null;
109-
if (!!formData.clusterID) {
109+
if (formData.clusterID) {
110110
selectedCluster = clusters.find((c) => c.id === formData.clusterID);
111111
}
112112

113113
let selectedKeyspace = null;
114-
if (!!formData.keyspace) {
114+
if (formData.keyspace) {
115115
selectedKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.keyspace);
116116
}
117117

web/vtadmin/src/components/routes/createWorkflow/CreateMaterialize.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,17 @@ export const CreateMaterialize = () => {
116116
);
117117

118118
let selectedCluster = null;
119-
if (!!formData.clusterID) {
119+
if (formData.clusterID) {
120120
selectedCluster = clusters.find((c) => c.id === formData.clusterID);
121121
}
122122

123123
let selectedSourceKeyspace = null;
124-
if (!!formData.sourceKeyspace) {
124+
if (formData.sourceKeyspace) {
125125
selectedSourceKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.sourceKeyspace);
126126
}
127127

128128
let selectedTargetKeyspace = null;
129-
if (!!formData.targetKeyspace) {
129+
if (formData.targetKeyspace) {
130130
selectedTargetKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.targetKeyspace);
131131
}
132132

web/vtadmin/src/components/routes/createWorkflow/CreateMoveTables.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ export const CreateMoveTables = () => {
112112
);
113113

114114
let selectedCluster = null;
115-
if (!!formData.clusterID) {
115+
if (formData.clusterID) {
116116
selectedCluster = clusters.find((c) => c.id === formData.clusterID);
117117
}
118118

119119
let selectedSourceKeyspace = null;
120-
if (!!formData.sourceKeyspace) {
120+
if (formData.sourceKeyspace) {
121121
selectedSourceKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.sourceKeyspace);
122122
}
123123

124124
let selectedTargetKeyspace = null;
125-
if (!!formData.targetKeyspace) {
125+
if (formData.targetKeyspace) {
126126
selectedTargetKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.targetKeyspace);
127127
}
128128

web/vtadmin/src/components/routes/createWorkflow/CreateReshard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ export const CreateReshard = () => {
116116
);
117117

118118
let selectedCluster = null;
119-
if (!!formData.clusterID) {
119+
if (formData.clusterID) {
120120
selectedCluster = clusters.find((c) => c.id === formData.clusterID);
121121
}
122122

123123
let selectedKeyspace = null;
124-
if (!!formData.keyspace) {
124+
if (formData.keyspace) {
125125
selectedKeyspace = keyspaces.find((ks) => ks.keyspace?.name === formData.keyspace);
126126
}
127127

0 commit comments

Comments
 (0)