Skip to content

Commit

Permalink
Upgrades TypeScript to 4.1, simplifies jest config
Browse files Browse the repository at this point in the history
* Addressing the `nth-check` CVE required bumping `css-select`, which
  is a dependency of `cheerio`. Bumping `cheerio` requires upgrading
  from TypeScript 4.0 to 4.1.
* TypeScript 4.1 introduces a set of [breaking changes](https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#breaking-changes).
  The main changes that impact Dashboards is that `resolve`'s parameters
  are no longer optional in `Promise`s, and that potentially undefined
  indexes must use the `!` non-null assertion operator.
* The upgrades to TypeScript and `cheerio` triggered some jest errors
  which prompted the upgrade to the `enzyme` dependencies.
* Merges files under `/src/test_utils` and `/src/dev/jest` into the
  `@osd/test` package to simplify.
* Fixes the naming of the `@osd/eslint-config-opensearch-dashboards`
  package.
* Fixes inconsistent plugin installation tests.

Resolves opensearch-project#1081

Signed-off-by: Tommy Markley <markleyt@amazon.com>
  • Loading branch information
Tommy Markley committed Mar 23, 2022
1 parent bd15433 commit f44d550
Show file tree
Hide file tree
Showing 388 changed files with 1,344 additions and 1,515 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Object.keys(require('eslint-plugin-mocha').rules).forEach((k) => {
module.exports = {
root: true,

extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'],
extends: ['@osd/eslint-config-opensearch-dashboards', 'plugin:@elastic/eui/recommended'],

overrides: [
/**
Expand Down
2 changes: 1 addition & 1 deletion examples/bfetch_explorer/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class BfetchExplorerPlugin implements Plugin {
// Validate inputs.
if (num < 0) throw new Error('Invalid number');
// Wait number of specified milliseconds.
await new Promise((r) => setTimeout(r, num));
await new Promise<void>((r) => setTimeout(r, num));
// Double the number and send it back.
return { num: 2 * num };
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const createEditBookAction = (getStartServices: () => Promise<StartServic
return savedObjectsClient.create(BOOK_EMBEDDABLE, attributes);
},
checkForDuplicateTitle: (props: OnSaveProps) => {
return new Promise(() => {
return new Promise<true>(() => {
return true;
});
},
Expand Down
2 changes: 1 addition & 1 deletion examples/state_containers_examples/public/todo/todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export const TodoAppPage: React.FC<{

function withDefaultState<State extends BaseState>(
stateContainer: BaseStateContainer<State>,
// eslint-disable-next-line no-shadow
// eslint-disable-next-line @typescript-eslint/no-shadow
defaultState: State
): INullableBaseStateContainer<State> {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function useGlobalStateSyncing(
}, [query, osdUrlStateStorage]);
}

// eslint-disable-next-line @typescript-eslint/no-shadow
function useAppStateSyncing<AppState extends QueryState>(
appStateContainer: BaseStateContainer<AppState>,
query: DataPublicPluginStart['query'],
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"**/minimist": "^1.2.5",
"**/node-jose": "^2.1.0",
"**/trim": "^0.0.3",
"**/typescript": "4.0.2"
"**/typescript": "4.1.6"
},
"workspaces": {
"packages": [
Expand Down Expand Up @@ -213,7 +213,6 @@
"@elastic/apm-rum": "^5.6.1",
"@elastic/charts": "23.2.2",
"@elastic/ems-client": "7.10.0",
"@elastic/eslint-config-kibana": "0.15.0",
"@elastic/eslint-plugin-eui": "0.0.2",
"@elastic/filesaver": "1.1.2",
"@elastic/github-checks-reporter": "0.0.20b3",
Expand All @@ -222,6 +221,7 @@
"@microsoft/api-extractor": "^7.19.3",
"@osd/babel-preset": "1.0.0",
"@osd/dev-utils": "1.0.0",
"@osd/eslint-config-opensearch-dashboards": "1.0.0",
"@osd/eslint-import-resolver-opensearch-dashboards": "2.0.0",
"@osd/eslint-plugin-eslint": "1.0.0",
"@osd/expect": "1.0.0",
Expand All @@ -246,7 +246,7 @@
"@types/babel__core": "^7.1.17",
"@types/bluebird": "^3.1.1",
"@types/chance": "^1.0.0",
"@types/cheerio": "^0.22.10",
"@types/cheerio": "^0.22.30",
"@types/chromedriver": "^81.0.0",
"@types/classnames": "^2.2.9",
"@types/color": "^3.0.0",
Expand All @@ -255,7 +255,7 @@
"@types/deep-freeze-strict": "^1.1.0",
"@types/delete-empty": "^2.0.0",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.10.5",
"@types/enzyme": "^3.10.11",
"@types/eslint": "^6.1.3",
"@types/fetch-mock": "^7.3.1",
"@types/flot": "^0.0.31",
Expand All @@ -270,6 +270,7 @@
"@types/has-ansi": "^3.0.0",
"@types/history": "^4.7.3",
"@types/hjson": "^2.4.2",
"@types/istanbul-lib-coverage": "^2.0.4",
"@types/jest": "^27.4.0",
"@types/joi": "^13.4.2",
"@types/jquery": "^3.3.31",
Expand Down Expand Up @@ -320,8 +321,8 @@
"@types/webpack": "^4.41.31",
"@types/webpack-env": "^1.16.3",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"angular-aria": "^1.8.0",
"angular-mocks": "^1.8.2",
"angular-recursion": "^1.0.5",
Expand All @@ -334,7 +335,7 @@
"brace": "0.11.1",
"chai": "3.5.0",
"chance": "1.0.18",
"cheerio": "0.22.0",
"cheerio": "^1.0.0-rc.10",
"chromedriver": "^91.0.1",
"classnames": "2.2.6",
"compare-versions": "3.5.1",
Expand All @@ -343,8 +344,8 @@
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-to-json": "^3.4.4",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.6.2",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-babel": "^5.3.1",
Expand All @@ -360,7 +361,7 @@
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-perf": "^3.2.3",
"exit-hook": "^2.2.0",
"fetch-mock": "^7.3.9",
Expand Down Expand Up @@ -437,7 +438,7 @@
"topojson-client": "3.0.0",
"tough-cookie": "^4.0.0",
"tree-kill": "^1.2.2",
"typescript": "4.0.2",
"typescript": "4.1.6",
"ui-select": "0.19.8",
"vega": "^5.17.3",
"vega-lite": "^4.16.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ in your `.eslintrc`:
```javascript
{
extends: [
'@elastic/eslint-config-kibana'
'@osd/eslint-config-opensearch-dashboards'
]
}
```

## Optional jest config

If the project uses the [jest test runner](https://facebook.github.io/jest/),
the `@elastic/eslint-config-kibana/jest` config can be extended as well to use
the `@osd/eslint-config-opensearch-dashboards/jest` config can be extended as well to use
`eslint-plugin-jest` and add settings specific to it:

```javascript
{
extends: [
'@elastic/eslint-config-kibana',
'@elastic/eslint-config-kibana/jest'
'@osd/eslint-config-opensearch-dashboards',
'@osd/eslint-config-opensearch-dashboards/jest'
]
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elastic/eslint-config-kibana",
"version": "0.15.0",
"name": "@osd/eslint-config-opensearch-dashboards",
"version": "1.0.0",
"description": "The eslint config used by the opensearch dashboards team",
"main": ".eslintrc.js",
"repository": {
Expand All @@ -18,8 +18,8 @@
},
"homepage": "https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/packages/opensearch-eslint-config-opensearch-dashboards",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"babel-eslint": "^10.0.3",
"eslint": "^6.8.0",
"eslint-plugin-babel": "^5.3.1",
Expand All @@ -32,6 +32,6 @@
"eslint-plugin-no-unsanitized": "^3.0.2",
"eslint-plugin-prefer-object-spread": "^1.2.1",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^4.0.4"
"eslint-plugin-react-hooks": "^4.2.0"
}
}
Loading

0 comments on commit f44d550

Please sign in to comment.