mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Warn in Typescript when using Array.flat() or .flatMap() without polyfill (#37558)
* Warn in Typescript when using Array.flat() or .flatMap() without polyfill * Update ecma version provided to babel in eslint * Update per review comments
This commit is contained in:
parent
fed933db21
commit
87ee9c2a9b
11 changed files with 19 additions and 19 deletions
|
@ -7,11 +7,11 @@ module.exports = {
|
|||
plugins: ['@kbn/eslint-plugin-eslint'],
|
||||
|
||||
parserOptions: {
|
||||
ecmaVersion: 6
|
||||
ecmaVersion: 2018
|
||||
},
|
||||
|
||||
env: {
|
||||
es6: true
|
||||
es6: true,
|
||||
},
|
||||
|
||||
rules: {
|
||||
|
|
|
@ -44,8 +44,7 @@ module.exports = {
|
|||
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 6,
|
||||
ecmaFeatures: { experimentalObjectRestSpread: true },
|
||||
ecmaVersion: 2018,
|
||||
},
|
||||
|
||||
rules: {
|
||||
|
|
|
@ -42,9 +42,8 @@ module.exports = {
|
|||
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 6,
|
||||
ecmaVersion: 2018,
|
||||
ecmaFeatures: {
|
||||
experimentalObjectRestSpread: true,
|
||||
jsx: true
|
||||
},
|
||||
// NOTE: That is to avoid a known performance issue related with the `ts.Program` used by
|
||||
|
|
|
@ -24,7 +24,7 @@ const dedent = require('dedent');
|
|||
const ruleTester = new RuleTester({
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
ecmaVersion: 2015,
|
||||
ecmaVersion: 2018,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const ruleTester = new RuleTester({
|
|||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 2015,
|
||||
ecmaVersion: 2018,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ const dedent = require('dedent');
|
|||
const ruleTester = new RuleTester({
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
ecmaVersion: 2015,
|
||||
ecmaVersion: 2018,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"lib": [
|
||||
"esnext"
|
||||
"es2018"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
"strict": true,
|
||||
// enables "core language features"
|
||||
"lib": [
|
||||
// ESNext auto includes previous versions all the way back to es5
|
||||
"esnext",
|
||||
// ES2018 includes previous versions all the way back to es5
|
||||
// We are not using esnext because @babel/polyfill is on core-js 2, not 3
|
||||
"es2018",
|
||||
// includes support for browser APIs
|
||||
"dom"
|
||||
],
|
||||
|
|
|
@ -57,8 +57,8 @@ function getYTickFormatter(chart: GenericMetricsChart) {
|
|||
switch (chart.yUnit) {
|
||||
case 'bytes': {
|
||||
const max = Math.max(
|
||||
...chart.series.flatMap(series =>
|
||||
series.data.map(coord => coord.y || 0)
|
||||
...chart.series.map(({ data }) =>
|
||||
Math.max(...data.map(({ y }) => y || 0))
|
||||
)
|
||||
);
|
||||
return getFixedByteFormatter(max);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"extends": "../../../../../tsconfig",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["esnext", "dom"],
|
||||
"lib": ["es2018", "dom"],
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": false,
|
||||
|
|
|
@ -73,10 +73,11 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols =>
|
|||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
const subTree = tree
|
||||
.filter(s => s.members)
|
||||
.map(s => s.members)
|
||||
.flat();
|
||||
// TODO: Use Array.flat once supported
|
||||
const subTree = tree.reduce(
|
||||
(s, t) => (t.members ? s.concat(t.members) : s),
|
||||
[] as SymbolWithMembers[]
|
||||
);
|
||||
if (subTree.length > 0) {
|
||||
return findContainer(subTree, containerName);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue