Skip to content

Commit

Permalink
[eslint] enable type-specific lint rules (#114184)
Browse files Browse the repository at this point in the history
* [eslint] enable type-specific lint rules

* autofix violations

* duplicate eslint-disable to new export statement

Co-authored-by: spalger <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored Nov 3, 2021
1 parent c6db498 commit 4385ac4
Show file tree
Hide file tree
Showing 641 changed files with 2,242 additions and 1,852 deletions.
7 changes: 7 additions & 0 deletions .buildkite/pipelines/hourly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ steps:
key: linting
timeout_in_minutes: 90

- command: .buildkite/scripts/steps/lint_with_types.sh
label: 'Linting (with types)'
agents:
queue: c2-16
key: linting_with_types
timeout_in_minutes: 90

- command: .buildkite/scripts/steps/checks.sh
label: 'Checks'
agents:
Expand Down
7 changes: 7 additions & 0 deletions .buildkite/pipelines/pull_request/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ steps:
key: linting
timeout_in_minutes: 90

- command: .buildkite/scripts/steps/lint_with_types.sh
label: 'Linting (with types)'
agents:
queue: c2-16
key: linting_with_types
timeout_in_minutes: 90

- command: .buildkite/scripts/steps/checks.sh
label: 'Checks'
agents:
Expand Down
12 changes: 12 additions & 0 deletions .buildkite/scripts/steps/lint_with_types.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

export BUILD_TS_REFS_DISABLE=false
.buildkite/scripts/bootstrap.sh

echo '--- Lint: eslint (with types)'
checks-reporter-with-killswitch "Lint: eslint (with types)" \
node scripts/eslint_with_types
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ target
.idea
*.iml
*.log
types.eslint.config.js

# Ignore example plugin builds
/examples/*/build
Expand Down
2 changes: 1 addition & 1 deletion examples/developer_examples/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ import { DeveloperExamplesPlugin } from './plugin';

export const plugin = () => new DeveloperExamplesPlugin();

export { DeveloperExamplesSetup } from './plugin';
export type { DeveloperExamplesSetup } from './plugin';
5 changes: 3 additions & 2 deletions examples/embeddable_examples/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
* Side Public License, v 1.
*/

export { TodoSavedObjectAttributes } from './todo_saved_object_attributes';
export { BookSavedObjectAttributes, BOOK_SAVED_OBJECT } from './book_saved_object_attributes';
export type { TodoSavedObjectAttributes } from './todo_saved_object_attributes';
export type { BookSavedObjectAttributes } from './book_saved_object_attributes';
export { BOOK_SAVED_OBJECT } from './book_saved_object_attributes';
18 changes: 9 additions & 9 deletions examples/embeddable_examples/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
* Side Public License, v 1.
*/

export type { HelloWorldEmbeddableFactory } from './hello_world';
export {
HELLO_WORLD_EMBEDDABLE,
HelloWorldEmbeddable,
HelloWorldEmbeddableFactoryDefinition,
HelloWorldEmbeddableFactory,
} from './hello_world';
export { ListContainer, LIST_CONTAINER, ListContainerFactory } from './list_container';
export { TODO_EMBEDDABLE, TodoEmbeddableFactory } from './todo';
export type { ListContainerFactory } from './list_container';
export { ListContainer, LIST_CONTAINER } from './list_container';
export type { TodoEmbeddableFactory } from './todo';
export { TODO_EMBEDDABLE } from './todo';

export { BOOK_EMBEDDABLE } from './book';

export { SIMPLE_EMBEDDABLE } from './migrations';

import { EmbeddableExamplesPlugin } from './plugin';

export {
SearchableListContainer,
SEARCHABLE_LIST_CONTAINER,
SearchableListContainerFactory,
} from './searchable_list_container';
export { MULTI_TASK_TODO_EMBEDDABLE, MultiTaskTodoEmbeddableFactory } from './multi_task_todo';
export type { SearchableListContainerFactory } from './searchable_list_container';
export { SearchableListContainer, SEARCHABLE_LIST_CONTAINER } from './searchable_list_container';
export type { MultiTaskTodoEmbeddableFactory } from './multi_task_todo';
export { MULTI_TASK_TODO_EMBEDDABLE } from './multi_task_todo';
export const plugin = () => new EmbeddableExamplesPlugin();
3 changes: 2 additions & 1 deletion examples/embeddable_examples/public/list_container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
*/

export { ListContainer, LIST_CONTAINER } from './list_container';
export { ListContainerFactoryDefinition, ListContainerFactory } from './list_container_factory';
export type { ListContainerFactory } from './list_container_factory';
export { ListContainerFactoryDefinition } from './list_container_factory';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
*/

export { SearchableListContainer, SEARCHABLE_LIST_CONTAINER } from './searchable_list_container';
export {
SearchableListContainerFactoryDefinition,
SearchableListContainerFactory,
} from './searchable_list_container_factory';
export type { SearchableListContainerFactory } from './searchable_list_container_factory';
export { SearchableListContainerFactoryDefinition } from './searchable_list_container_factory';
4 changes: 2 additions & 2 deletions examples/locator_examples/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import { LocatorExamplesPlugin } from './plugin';

export {
export type {
HelloLocator,
HelloLocatorV1Params,
HelloLocatorV2Params,
HelloLocatorParams,
HELLO_LOCATOR,
} from './locator';
export { HELLO_LOCATOR } from './locator';

export const plugin = () => new LocatorExamplesPlugin();
2 changes: 1 addition & 1 deletion examples/search_examples/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ import { SearchExamplesPlugin } from './plugin';
export function plugin() {
return new SearchExamplesPlugin();
}
export { SearchExamplesPluginSetup, SearchExamplesPluginStart } from './types';
export type { SearchExamplesPluginSetup, SearchExamplesPluginStart } from './types';
2 changes: 1 addition & 1 deletion examples/search_examples/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export function plugin(initializerContext: PluginInitializerContext) {
return new SearchExamplesPlugin(initializerContext);
}

export { SearchExamplesPluginSetup, SearchExamplesPluginStart } from './types';
export type { SearchExamplesPluginSetup, SearchExamplesPluginStart } from './types';
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,9 @@
"@types/xml2js": "^0.4.5",
"@types/yauzl": "^2.9.1",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"@typescript-eslint/typescript-estree": "^4.31.2",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
"@typescript-eslint/typescript-estree": "^5.2.0",
"@yarnpkg/lockfile": "^1.1.0",
"abab": "^2.0.4",
"aggregate-error": "^3.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-config-schema/src/duration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*/

import { Duration, duration as momentDuration, DurationInputArg2, isDuration } from 'moment';
export { Duration, isDuration };
export type { Duration };
export { isDuration };

const timeFormatRegex = /^(0|[1-9][0-9]*)(ms|s|m|h|d|w|M|Y)$/;

Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ import {
StreamType,
} from './types';

export { ObjectType, TypeOf, Type, Props, NullableProps };
export type { TypeOf, Props, NullableProps };
export { ObjectType, Type };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
export { isConfigSchema } from './typeguards';
Expand Down
36 changes: 24 additions & 12 deletions packages/kbn-config-schema/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,35 @@
* Side Public License, v 1.
*/

export { Type, TypeOptions } from './type';
export type { TypeOptions } from './type';
export { Type } from './type';
export { AnyType } from './any_type';
export { ArrayOptions, ArrayType } from './array_type';
export type { ArrayOptions } from './array_type';
export { ArrayType } from './array_type';
export { BooleanType } from './boolean_type';
export { BufferType } from './buffer_type';
export { ByteSizeOptions, ByteSizeType } from './byte_size_type';
export { ConditionalType, ConditionalTypeValue } from './conditional_type';
export { DurationOptions, DurationType } from './duration_type';
export type { ByteSizeOptions } from './byte_size_type';
export { ByteSizeType } from './byte_size_type';
export type { ConditionalTypeValue } from './conditional_type';
export { ConditionalType } from './conditional_type';
export type { DurationOptions } from './duration_type';
export { DurationType } from './duration_type';
export { LiteralType } from './literal_type';
export { MaybeType } from './maybe_type';
export { MapOfOptions, MapOfType } from './map_type';
export { NumberOptions, NumberType } from './number_type';
export { ObjectType, ObjectTypeOptions, Props, NullableProps, TypeOf } from './object_type';
export { RecordOfOptions, RecordOfType } from './record_type';
export type { MapOfOptions } from './map_type';
export { MapOfType } from './map_type';
export type { NumberOptions } from './number_type';
export { NumberType } from './number_type';
export type { ObjectTypeOptions, Props, NullableProps, TypeOf } from './object_type';
export { ObjectType } from './object_type';
export type { RecordOfOptions } from './record_type';
export { RecordOfType } from './record_type';
export { StreamType } from './stream_type';
export { StringOptions, StringType } from './string_type';
export type { StringOptions } from './string_type';
export { StringType } from './string_type';
export { UnionType } from './union_type';
export { URIOptions, URIType } from './uri_type';
export type { URIOptions } from './uri_type';
export { URIType } from './uri_type';
export { NeverType } from './never_type';
export { IpType, IpOptions } from './ip_type';
export type { IpOptions } from './ip_type';
export { IpType } from './ip_type';
19 changes: 9 additions & 10 deletions packages/kbn-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ export type {

export { applyDeprecations, configDeprecationFactory } from './deprecation';

export {
RawConfigurationProvider,
RawConfigService,
RawConfigAdapter,
getConfigFromFiles,
} from './raw';
export type { RawConfigurationProvider, RawConfigAdapter } from './raw';
export { RawConfigService, getConfigFromFiles } from './raw';

export { ConfigService, IConfigService, ConfigValidateParameters } from './config_service';
export { Config, ConfigPath, isConfigPath, hasConfigPathIntersection } from './config';
export type { IConfigService, ConfigValidateParameters } from './config_service';
export { ConfigService } from './config_service';
export type { Config, ConfigPath } from './config';
export { isConfigPath, hasConfigPathIntersection } from './config';
export { ObjectToConfigAdapter } from './object_to_config_adapter';
export { CliArgs, Env, RawPackageInfo } from './env';
export { EnvironmentMode, PackageInfo } from './types';
export type { CliArgs, RawPackageInfo } from './env';
export { Env } from './env';
export type { EnvironmentMode, PackageInfo } from './types';
export { getPluginSearchPaths } from './plugins';
3 changes: 2 additions & 1 deletion packages/kbn-config/src/raw/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
* Side Public License, v 1.
*/

export { RawConfigService, RawConfigurationProvider, RawConfigAdapter } from './raw_config_service';
export type { RawConfigurationProvider, RawConfigAdapter } from './raw_config_service';
export { RawConfigService } from './raw_config_service';
export { getConfigFromFiles } from './read_config';
23 changes: 0 additions & 23 deletions packages/kbn-dev-utils/src/proc_runner/errors.ts

This file was deleted.

8 changes: 5 additions & 3 deletions packages/kbn-dev-utils/src/proc_runner/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const treeKillAsync = promisify((...args: [number, string, any]) => treeKill(...

import { ToolingLog } from '../tooling_log';
import { observeLines } from '../stdio';
import { createCliError } from './errors';
import { createFailError } from '../run';

const SECOND = 1000;
const STOP_TIMEOUT = 30 * SECOND;
Expand Down Expand Up @@ -57,7 +57,7 @@ export type Proc = ReturnType<typeof startProc>;
export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
const { cmd, args, cwd, env, stdin } = options;

log.info('[%s] > %s', name, cmd, args.join(' '));
log.info('[%s] > %s', name, cmd === process.execPath ? 'node' : cmd, args.join(' '));

// spawn fails with ENOENT when either the
// cmd or cwd don't exist, so we check for the cwd
Expand Down Expand Up @@ -97,7 +97,9 @@ export function startProc(name: string, options: ProcOptions, log: ToolingLog) {
}
// JVM exits with 143 on SIGTERM and 130 on SIGINT, dont' treat then as errors
if (code > 0 && !(code === 143 || code === 130)) {
throw createCliError(`[${name}] exited with code ${code}`);
throw createFailError(`[${name}] exited with code ${code}`, {
exitCode: code,
});
}

return code;
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-dev-utils/src/proc_runner/proc_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { filter, first, catchError, map } from 'rxjs/operators';
import exitHook from 'exit-hook';

import { ToolingLog } from '../tooling_log';
import { createCliError } from './errors';
import { createFailError } from '../run';
import { Proc, ProcOptions, startProc } from './proc';

const SECOND = 1000;
Expand Down Expand Up @@ -61,14 +61,14 @@ export class ProcRunner {
*/
async run(name: string, options: RunOptions) {
const {
cmd,
args = [],
cwd = process.cwd(),
stdin = undefined,
wait = false,
waitTimeout = 15 * MINUTE,
env = process.env,
} = options;
const cmd = options.cmd === 'node' ? process.execPath : options.cmd;

if (this.closing) {
throw new Error('ProcRunner is closing');
Expand Down Expand Up @@ -99,7 +99,7 @@ export class ProcRunner {
first(),
catchError((err) => {
if (err.name !== 'EmptyError') {
throw createCliError(`[${name}] exited without matching pattern: ${wait}`);
throw createFailError(`[${name}] exited without matching pattern: ${wait}`);
} else {
throw err;
}
Expand All @@ -110,7 +110,7 @@ export class ProcRunner {
: Rx.timer(waitTimeout).pipe(
map(() => {
const sec = waitTimeout / SECOND;
throw createCliError(
throw createFailError(
`[${name}] failed to match pattern within ${sec} seconds [pattern=${wait}]`
);
})
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-dev-utils/src/tooling_log/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

export { ToolingLog } from './tooling_log';
export type { ToolingLogOptions } from './tooling_log';
export { ToolingLogTextWriter, ToolingLogTextWriterConfig } from './tooling_log_text_writer';
export { pickLevelFromFlags, parseLogLevel, LogLevel, ParsedLogLevel } from './log_levels';
export type { ToolingLogTextWriterConfig } from './tooling_log_text_writer';
export { ToolingLogTextWriter } from './tooling_log_text_writer';
export type { LogLevel, ParsedLogLevel } from './log_levels';
export { pickLevelFromFlags, parseLogLevel } from './log_levels';
export { ToolingLogCollectingWriter } from './tooling_log_collecting_writer';
export type { Writer } from './writer';
export type { Message } from './message';
3 changes: 2 additions & 1 deletion packages/kbn-es-archiver/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export {

export { createFilterRecordsStream } from './records';

export { createStats, Stats } from './stats';
export type { Stats } from './stats';
export { createStats } from './stats';

export {
isGzip,
Expand Down
5 changes: 3 additions & 2 deletions packages/kbn-es-query/src/es_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
*/

export { migrateFilter } from './migrate_filter';
export { buildEsQuery, EsQueryConfig } from './build_es_query';
export type { EsQueryConfig } from './build_es_query';
export { buildEsQuery } from './build_es_query';
export { buildQueryFromFilters } from './from_filters';
export { luceneStringToDsl } from './lucene_string_to_dsl';
export { decorateQuery } from './decorate_query';
export {
export type {
IndexPatternBase,
IndexPatternFieldBase,
IFieldSubType,
Expand Down
Loading

0 comments on commit 4385ac4

Please sign in to comment.