Skip to content

Commit

Permalink
Update eslint related packages (#48513)
Browse files Browse the repository at this point in the history
* Update eslint related packages

* add errorMessage to no-restricted-paths validation

* add license to eslintrc file

* ignore broken plugin fixture

* upgrade tangled peer deps

* give name to unnamed func to avoid typescript-eslint/typescript-eslint#1078

* migrate away from removed prefer-interface

* migrate away from removed no-angle-bracket-type-assertions rule

* migrate away from removed no-triple-slash-reference rule

* old config was invalid and made this rule a noop

* fix array-type rule config

* fix readonly paramProperties that weren't being checked

* fix propType ordering

* remove references to non-existent rules

* remove unnecessary disable that is improperly formatted

* fix comment-related spacing

* fix typo/invalid namespace overrides

* rename fn to avoid hook-alike behavior

* remove reference to old removed rule

* use caret version for prettier

* reference babel-eslint with absolute path
  • Loading branch information
renovate[bot] authored and Spencer committed Oct 21, 2019
1 parent 603e27e commit feceb0f
Show file tree
Hide file tree
Showing 69 changed files with 361 additions and 291 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bower_components
/x-pack/legacy/plugins/infra/public/graphql/types.ts
/x-pack/legacy/plugins/infra/server/graphql/types.ts
/x-pack/legacy/plugins/apm/cypress/**/snapshots.js
/src/legacy/plugin_discovery/plugin_pack/__tests__/fixtures/plugins/broken
**/graphql/types.ts
**/*.js.snap
!/.eslintrc.js
20 changes: 19 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

const { readdirSync } = require('fs');
const { resolve } = require('path');

Expand Down Expand Up @@ -622,7 +641,6 @@ module.exports = {
// will introduced after the other warns are fixed
// 'react/sort-comp': 'error',
'react/void-dom-elements-no-children': 'error',
'react/jsx-boolean-value': ['error', 'warn'],
// will introduced after the other warns are fixed
// 'react/jsx-no-bind': 'error',
'react/jsx-no-comment-textnodes': 'error',
Expand Down
2 changes: 1 addition & 1 deletion kibana.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import * as LegacyKibanaServer from './src/legacy/server/kbn_server';
/**
* Re-export legacy types under a namespace.
*/
// eslint-disable-next-line @typescript/eslint-no-namespace
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Legacy {
export type IndexPatternsService = LegacyKibanaServer.IndexPatternsService;
export type KibanaConfig = LegacyKibanaServer.KibanaConfig;
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
"@types/delete-empty": "^2.0.0",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.9.0",
"@types/eslint": "^4.16.8",
"@types/eslint": "^6.1.2",
"@types/execa": "^0.9.0",
"@types/fetch-mock": "^7.3.1",
"@types/getopts": "^2.0.1",
Expand Down Expand Up @@ -352,8 +352,8 @@
"@types/uuid": "^3.4.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"angular-mocks": "^1.7.8",
"archiver": "^3.1.1",
"babel-eslint": "^10.0.3",
Expand All @@ -373,21 +373,21 @@
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-adapter-utils": "^1.12.0",
"enzyme-to-json": "^3.3.4",
"eslint": "5.16.0",
"eslint-config-prettier": "6.3.0",
"eslint": "^6.5.1",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-ban": "1.3.0",
"eslint-plugin-cypress": "^2.6.1",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "22.17.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-mocha": "6.1.1",
"eslint-plugin-no-unsanitized": "3.0.2",
"eslint-plugin-node": "9.2.0",
"eslint-plugin-prefer-object-spread": "1.2.1",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react": "7.13.0",
"eslint-plugin-react-hooks": "1.6.0",
"eslint-plugin-ban": "^1.3.0",
"eslint-plugin-cypress": "^2.7.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.19.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^6.2.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.1.2",
"exit-hook": "^2.2.0",
"faker": "1.1.0",
"fetch-mock": "^7.3.9",
Expand Down Expand Up @@ -438,7 +438,7 @@
"pngjs": "^3.4.0",
"postcss": "^7.0.5",
"postcss-url": "^8.0.0",
"prettier": "1.18.2",
"prettier": "^1.18.2",
"proxyquire": "1.8.0",
"regenerate": "^1.4.0",
"sass-lint": "^1.12.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-kibana/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
*/
{
files: ['**/*.js'],
parser: 'babel-eslint',
parser: require.resolve('babel-eslint'),

plugins: [
'mocha',
Expand Down
24 changes: 12 additions & 12 deletions packages/eslint-config-kibana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
},
"homepage": "https://github.com/elastic/eslint-config-kibana#readme",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"babel-eslint": "^10.0.3",
"eslint": "5.16.0",
"eslint": "^6.5.1",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-ban": "1.3.0",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-mocha": "^6.1.1",
"eslint-plugin-no-unsanitized": "3.0.2",
"eslint-plugin-prefer-object-spread": "1.2.1",
"eslint-plugin-react": "7.13.0",
"eslint-plugin-react-hooks": "1.6.0"
"eslint-plugin-ban": "^1.3.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.19.0",
"eslint-plugin-mocha": "^6.2.0",
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.1.2"
}
}
12 changes: 8 additions & 4 deletions packages/eslint-config-kibana/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
//
// Old recommended tslint rules
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': ['error', 'array-simple'],
'@typescript-eslint/array-type': ['error', { default: 'array-simple', readonly: 'array-simple' }],
'@typescript-eslint/ban-types': 'error',
'camelcase': 'off',
'@typescript-eslint/camelcase': ['error', {
Expand All @@ -92,15 +92,19 @@ module.exports = {
'indent': 'off',
'@typescript-eslint/indent': [ 'error', 2, { SwitchCase: 1 } ],
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-interface': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/member-ordering': ['error', {
'default': ['public-static-field', 'static-field', 'instance-field']
}],
'@typescript-eslint/no-angle-bracket-type-assertion': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-triple-slash-reference': 'error',
'@typescript-eslint/triple-slash-reference': ['error', {
path: 'never',
types: 'never',
lib: 'never'
}],
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unified-signatures': 'error',
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-es/src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
const os = require('os');
const path = require('path');

function useBat(bin) {
function maybeUseBat(bin) {
return os.platform().startsWith('win') ? `${bin}.bat` : bin;
}

const tempDir = os.tmpdir();

exports.BASE_PATH = path.resolve(tempDir, 'kbn-es');

exports.GRADLE_BIN = useBat('./gradlew');
exports.ES_BIN = useBat('bin/elasticsearch');
exports.GRADLE_BIN = maybeUseBat('./gradlew');
exports.ES_BIN = maybeUseBat('bin/elasticsearch');
exports.ES_CONFIG = 'config/elasticsearch.yml';

exports.ES_KEYSTORE_BIN = useBat('./bin/elasticsearch-keystore');
exports.ES_KEYSTORE_BIN = maybeUseBat('./bin/elasticsearch-keystore');
2 changes: 1 addition & 1 deletion packages/kbn-eslint-plugin-eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"license": "Apache-2.0",
"peerDependencies": {
"eslint": "5.16.0",
"eslint": "6.5.1",
"babel-eslint": "^10.0.3"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const rule = require('../disallow_license_headers');
const dedent = require('dedent');

const ruleTester = new RuleTester({
parser: 'babel-eslint',
parser: require.resolve('babel-eslint'),
parserOptions: {
ecmaVersion: 2018,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const { RuleTester } = require('eslint');
const rule = require('../no_restricted_paths');

const ruleTester = new RuleTester({
parser: 'babel-eslint',
parser: require.resolve('babel-eslint'),
parserOptions: {
sourceType: 'module',
ecmaVersion: 2018,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const rule = require('../require_license_header');
const dedent = require('dedent');

const ruleTester = new RuleTester({
parser: 'babel-eslint',
parser: require.resolve('babel-eslint'),
parserOptions: {
ecmaVersion: 2018,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module.exports = {
anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],
},
allowSameFolder: { type: 'boolean' },
errorMessage: { type: 'string' },
},
additionalProperties: false,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-test-subj-selector/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
*/

// eslint-disable-next-line import/no-default-export
export default function(selector: string): string;
export default function kbnTestSubjSelector(selector: string): string;
2 changes: 1 addition & 1 deletion src/core/public/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class PluginWrapper<
private instance?: Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

constructor(
readonly discoveredPlugin: DiscoveredPlugin,
public readonly discoveredPlugin: DiscoveredPlugin,
public readonly opaqueId: PluginOpaqueId,
private readonly initializerContext: PluginInitializerContext
) {
Expand Down
1 change: 0 additions & 1 deletion src/core/public/saved_objects/simple_saved_object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { SavedObjectsClient } from './saved_objects_client';
export class SimpleSavedObject<T extends SavedObjectAttributes> {
public attributes: T;
// We want to use the same interface this class had in JS
// eslint-disable-next-line variable-name
public _version?: SavedObjectType<T>['version'];
public id: SavedObjectType<T>['id'];
public type: SavedObjectType<T>['type'];
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Env {
/**
* @internal
*/
constructor(readonly homeDir: string, options: EnvOptions) {
constructor(public readonly homeDir: string, options: EnvOptions) {
this.configDir = resolve(this.homeDir, 'config');
this.binDir = resolve(this.homeDir, 'bin');
this.logDir = resolve(this.homeDir, 'log');
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/config/raw_config_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class RawConfigService {
private readonly config$: Observable<Config>;

constructor(
readonly configFiles: readonly string[],
public readonly configFiles: readonly string[],
configAdapter: (rawConfig: Record<string, any>) => Config = rawConfig =>
new ObjectToConfigAdapter(rawConfig)
) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/http/router/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export class KibanaRequest<Params = unknown, Query = unknown, Body = unknown> {

constructor(
request: Request,
readonly params: Params,
readonly query: Query,
readonly body: Body,
public readonly params: Params,
public readonly query: Query,
public readonly body: Body,
// @ts-ignore we will use this flag as soon as http request proxy is supported in the core
// until that time we have to expose all the headers
private readonly withoutSecretHeaders: boolean
Expand Down
6 changes: 3 additions & 3 deletions src/core/server/http/router/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export function isKibanaResponse(response: Record<string, any>): response is IKi
export class KibanaResponse<T extends HttpResponsePayload | ResponseError = any>
implements IKibanaResponse<T> {
constructor(
readonly status: number,
readonly payload?: T,
readonly options: HttpResponseOptions = {}
public readonly status: number,
public readonly payload?: T,
public readonly options: HttpResponseOptions = {}
) {}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/http/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Router implements IRouter {
public put: IRouter['put'];

constructor(
readonly routerPath: string,
public readonly routerPath: string,
private readonly log: Logger,
private readonly enhanceWithContext: ContextEnhancer<any, any, any>
) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/logging/log_level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class LogLevel {
}
}

private constructor(readonly id: LogLevelId, readonly value: number) {}
private constructor(public readonly id: LogLevelId, public readonly value: number) {}

/**
* Indicates whether current log level covers the one that is passed as an argument.
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class PluginWrapper<
private instance?: Plugin<TSetup, TStart, TPluginsSetup, TPluginsStart>;

constructor(
readonly params: {
public readonly params: {
readonly path: string;
readonly manifest: PluginManifest;
readonly opaqueId: PluginOpaqueId;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ import { validateConvertFilterToKueryNode } from './filter_utils';
// BEWARE: The SavedObjectClient depends on the implementation details of the SavedObjectsRepository
// so any breaking changes to this repository are considered breaking changes to the SavedObjectsClient.

// eslint-disable-next-line @typescript-eslint/prefer-interface
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Left<T> = {
tag: 'Left';
error: T;
};
// eslint-disable-next-line @typescript-eslint/prefer-interface
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type Right<T> = {
tag: 'Right';
value: T;
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class Server {
private readonly uiSettings: UiSettingsService;

constructor(
readonly config$: Observable<Config>,
readonly env: Env,
public readonly config$: Observable<Config>,
public readonly env: Env,
private readonly logger: LoggerFactory
) {
this.log = this.logger.get('server');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface FilterableContainerInput extends ContainerInput {
* https://github.com/microsoft/TypeScript/issues/15300 is fixed so we use a type
* here instead
*/
// eslint-disable-next-line @typescript-eslint/prefer-interface
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export type InheritedChildrenInput = {
filters: Filter[];
id?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const HELLO_WORLD_CONTAINER = 'HELLO_WORLD_CONTAINER';
* https://github.com/microsoft/TypeScript/issues/15300 is fixed so we use a type
* here instead
*/
// eslint-disable-next-line @typescript-eslint/prefer-interface
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
type InheritedInput = {
id: string;
viewMode: ViewMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

class FormattedData {
constructor(readonly raw: any, readonly formatted: any) {}
constructor(public readonly raw: any, public readonly formatted: any) {}
}

export { FormattedData };
Loading

0 comments on commit feceb0f

Please sign in to comment.