Skip to content

Commit 90f7699

Browse files
authored
Update typescript eslint to v4.8 (#83520) (#83677)
* update deps * update rules use type-aware @typescript-eslint/no-shadow instead of no-shadow. do not use no-undef, rely on TypeScript instead * fix or mute all lint errors * react-hooks eslint plugin fails on ? syntax * fix wrong typings in viz * remove React as a global type * fix eslint errors * update version to 4.8.1 * fix a new error
1 parent dd3ea9c commit 90f7699

File tree

74 files changed

+152
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+152
-155
lines changed

.eslintrc.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ module.exports = {
867867
'no-shadow-restricted-names': 'error',
868868
'no-sparse-arrays': 'error',
869869
'no-this-before-super': 'error',
870-
'no-undef': 'error',
870+
// rely on typescript
871+
'no-undef': 'off',
871872
'no-unreachable': 'error',
872873
'no-unsafe-finally': 'error',
873874
'no-useless-call': 'error',
@@ -1002,7 +1003,8 @@ module.exports = {
10021003
'no-shadow-restricted-names': 'error',
10031004
'no-sparse-arrays': 'error',
10041005
'no-this-before-super': 'error',
1005-
'no-undef': 'error',
1006+
// rely on typescript
1007+
'no-undef': 'off',
10061008
'no-unreachable': 'error',
10071009
'no-unsafe-finally': 'error',
10081010
'no-useless-call': 'error',

examples/state_containers_examples/public/todo/todo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export const TodoAppPage: React.FC<{
313313

314314
function withDefaultState<State extends BaseState>(
315315
stateContainer: BaseStateContainer<State>,
316-
// eslint-disable-next-line no-shadow
316+
// eslint-disable-next-line @typescript-eslint/no-shadow
317317
defaultState: State
318318
): INullableBaseStateContainer<State> {
319319
return {

examples/state_containers_examples/public/with_data_services/components/app.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ function useGlobalStateSyncing(
180180
}, [query, kbnUrlStateStorage]);
181181
}
182182

183+
// eslint-disable-next-line @typescript-eslint/no-shadow
183184
function useAppStateSyncing<AppState extends QueryState>(
184185
appStateContainer: BaseStateContainer<AppState>,
185186
query: DataPublicPluginStart['query'],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@
564564
"@types/xml2js": "^0.4.5",
565565
"@types/yauzl": "^2.9.1",
566566
"@types/zen-observable": "^0.8.0",
567-
"@typescript-eslint/eslint-plugin": "^3.10.0",
568-
"@typescript-eslint/parser": "^3.10.0",
567+
"@typescript-eslint/eslint-plugin": "^4.8.1",
568+
"@typescript-eslint/parser": "^4.8.1",
569569
"@welldone-software/why-did-you-render": "^5.0.0",
570570
"@yarnpkg/lockfile": "^1.1.0",
571571
"abab": "^1.0.4",
@@ -641,7 +641,7 @@
641641
"eslint-plugin-prefer-object-spread": "^1.2.1",
642642
"eslint-plugin-prettier": "^3.1.4",
643643
"eslint-plugin-react": "^7.20.3",
644-
"eslint-plugin-react-hooks": "^4.0.4",
644+
"eslint-plugin-react-hooks": "^4.2.0",
645645
"eslint-plugin-react-perf": "^3.2.3",
646646
"expose-loader": "^0.7.5",
647647
"faker": "1.1.0",

packages/elastic-eslint-config-kibana/typescript.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ module.exports = {
190190
'@typescript-eslint/no-extra-non-null-assertion': 'error',
191191
'@typescript-eslint/no-misused-new': 'error',
192192
'@typescript-eslint/no-namespace': 'error',
193+
'@typescript-eslint/no-shadow': 'error',
194+
// rely on typescript
195+
'@typescript-eslint/no-undef': 'off',
196+
'no-undef': 'off',
197+
193198
'@typescript-eslint/triple-slash-reference': ['error', {
194199
path: 'never',
195200
types: 'never',
@@ -219,7 +224,6 @@ module.exports = {
219224
'no-eval': 'error',
220225
'no-new-wrappers': 'error',
221226
'no-script-url': 'error',
222-
'no-shadow': 'error',
223227
'no-throw-literal': 'error',
224228
'no-undef-init': 'error',
225229
'no-unsafe-finally': 'error',

src/core/public/utils/crypto/sha256.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ type BufferEncoding =
130130
| 'binary'
131131
| 'hex';
132132

133-
/* eslint-disable no-bitwise, no-shadow */
133+
/* eslint-disable no-bitwise, @typescript-eslint/no-shadow */
134134
export class Sha256 {
135135
private _a: number;
136136
private _b: number;

src/core/server/http/router/validator/validator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export type RouteValidatorFullConfig<P, Q, B> = RouteValidatorConfig<P, Q, B> &
143143
* @internal
144144
*/
145145
export class RouteValidator<P = {}, Q = {}, B = {}> {
146-
public static from<P = {}, Q = {}, B = {}>(
147-
opts: RouteValidator<P, Q, B> | RouteValidatorFullConfig<P, Q, B>
146+
public static from<_P = {}, _Q = {}, _B = {}>(
147+
opts: RouteValidator<_P, _Q, _B> | RouteValidatorFullConfig<_P, _Q, _B>
148148
) {
149149
if (opts instanceof RouteValidator) {
150150
return opts;

src/plugins/es_ui_shared/static/forms/hook_form_lib/hooks/use_field.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,16 @@ export const useField = <T, FormType = FormData, I = T>(
118118
* updating the "value" state.
119119
*/
120120
const formatInputValue = useCallback(
121-
<T>(inputValue: unknown): T => {
121+
<U>(inputValue: unknown): U => {
122122
const isEmptyString = typeof inputValue === 'string' && inputValue.trim() === '';
123123

124124
if (isEmptyString || !formatters) {
125-
return inputValue as T;
125+
return inputValue as U;
126126
}
127127

128128
const formData = __getFormData$().value;
129129

130-
return formatters.reduce((output, formatter) => formatter(output, formData), inputValue) as T;
130+
return formatters.reduce((output, formatter) => formatter(output, formData), inputValue) as U;
131131
},
132132
[formatters, __getFormData$]
133133
);

src/plugins/kibana_utils/common/state_containers/create_state_container_react_helpers.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ test('context receives stateContainer', () => {
9797
const { Provider, context } = createStateContainerReactHelpers<typeof stateContainer>();
9898

9999
ReactDOM.render(
100-
/* eslint-disable no-shadow */
100+
/* eslint-disable @typescript-eslint/no-shadow */
101101
<Provider value={stateContainer}>
102102
<context.Consumer>{(stateContainer) => stateContainer.get().foo}</context.Consumer>
103103
</Provider>,
104-
/* eslint-enable no-shadow */
104+
/* eslint-enable @typescript-eslint/no-shadow */
105105
container
106106
);
107107

@@ -116,7 +116,7 @@ describe('hooks', () => {
116116
const stateContainer = createStateContainer({ foo: 'bar' });
117117
const { Provider, useContainer } = createStateContainerReactHelpers<typeof stateContainer>();
118118
const Demo: React.FC<{}> = () => {
119-
// eslint-disable-next-line no-shadow
119+
// eslint-disable-next-line @typescript-eslint/no-shadow
120120
const stateContainer = useContainer();
121121
return <>{stateContainer.get().foo}</>;
122122
};

src/plugins/kibana_utils/demos/state_sync/url.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ export const result = Promise.resolve()
5656
});
5757

5858
function withDefaultState<State extends BaseState>(
59-
// eslint-disable-next-line no-shadow
59+
// eslint-disable-next-line @typescript-eslint/no-shadow
6060
stateContainer: BaseStateContainer<State>,
61-
// eslint-disable-next-line no-shadow
61+
// eslint-disable-next-line @typescript-eslint/no-shadow
6262
defaultState: State
6363
): INullableBaseStateContainer<State> {
6464
return {

0 commit comments

Comments
 (0)