Skip to content

Commit

Permalink
[eslint] automatically determine dev packages (#127089) (#127147)
Browse files Browse the repository at this point in the history
* [eslint] automatically determine dev packages

* remove old eslint overrides that are not needed anymore

(cherry picked from commit 1f514d7)

# Conflicts:
#	.eslintrc.js
#	packages/kbn-type-summarizer/package.json
  • Loading branch information
Spencer authored Mar 8, 2022
1 parent af85c51 commit b6055b6
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 26 deletions.
29 changes: 14 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* Side Public License, v 1.
*/

const Path = require('path');
const Fs = require('fs');

const globby = require('globby');

const APACHE_2_0_LICENSE_HEADER = `
/*
* Licensed to Elasticsearch B.V. under one or more contributor
Expand Down Expand Up @@ -89,22 +94,16 @@ const SAFER_LODASH_SET_DEFINITELYTYPED_HEADER = `
*/
`;

const packagePkgJsons = globby.sync('*/package.json', {
cwd: Path.resolve(__dirname, 'packages'),
absolute: true,
});

/** Packages which should not be included within production code. */
const DEV_PACKAGES = [
'kbn-babel-code-parser',
'kbn-dev-utils',
'kbn-cli-dev-mode',
'kbn-docs-utils',
'kbn-es*',
'kbn-eslint*',
'kbn-optimizer',
'kbn-plugin-generator',
'kbn-plugin-helpers',
'kbn-pm',
'kbn-storybook',
'kbn-telemetry-tools',
'kbn-test',
];
const DEV_PACKAGES = packagePkgJsons.flatMap((path) => {
const pkg = JSON.parse(Fs.readFileSync(path, 'utf8'));
return pkg.kibana && pkg.kibana.devOnly ? Path.dirname(Path.basename(path)) : [];
});

/** Directories (at any depth) which include dev-only code. */
const DEV_DIRECTORIES = [
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-babel-code-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"repository": {
"type": "git",
"url": "https://github.com/elastic/kibana/tree/main/packages/kbn-babel-code-parser"
},
"kibana": {
"devOnly": true
}
}
5 changes: 4 additions & 1 deletion packages/kbn-optimizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "./target_node/index.js"
"main": "./target_node/index.js",
"kibana": {
"devOnly": true
}
}
5 changes: 4 additions & 1 deletion packages/kbn-plugin-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"version": "1.0.0",
"private": true,
"license": "SSPL-1.0 OR Elastic License 2.0",
"main": "target_node/index.js"
"main": "target_node/index.js",
"kibana": {
"devOnly": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { MethodKeysOf } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicContract } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { PublicKeys } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable, expectNotAssignable } from 'tsd';
import { PublicMethodsOf } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectType } from 'tsd';
import { ShallowPromise } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnionToIntersection } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { UnwrapObservable, ObservableLike } from '../..';

Expand Down
1 change: 0 additions & 1 deletion packages/kbn-utility-types/src/tsd_tests/test_d/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Values } from '../..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Side Public License, v 1.
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { expectAssignable } from 'tsd';
import { Writable } from '../..';

Expand Down

0 comments on commit b6055b6

Please sign in to comment.