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 requires 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 Apr 13, 2022
1 parent 7bc0f85 commit e15c939
Show file tree
Hide file tree
Showing 387 changed files with 1,148 additions and 1,441 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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 @@ -65,7 +65,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 @@ -80,7 +80,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 @@ -324,7 +324,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 @@ -191,6 +191,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: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@
"resolutions": {
"**/@types/node": "^14.17.32",
"**/ansi-regex": "^5.0.1",
"**/nth-check": "^2.0.1",
"**/glob-parent": "^6.0.0",
"**/hoist-non-react-statics": "^3.3.2",
"**/json-schema": "^0.4.0",
"**/kind-of": ">=6.0.3",
"**/node-jose": "^2.1.0",
"**/qs": "^6.10.3",
"**/trim": "^0.0.3",
"**/typescript": "4.0.2",
"**/@types/react": "^16.14.23"
"**/typescript": "4.1.6"
},
"workspaces": {
"packages": [
Expand Down Expand Up @@ -214,7 +212,6 @@
"@elastic/apm-rum": "^5.6.1",
"@elastic/charts": "31.1.0",
"@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 @@ -223,6 +220,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 Down Expand Up @@ -255,7 +253,7 @@
"@types/deep-freeze-strict": "^1.1.0",
"@types/delete-empty": "^2.0.0",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.10.7",
"@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 +268,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 +319,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 +333,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.3.1",
"compare-versions": "3.5.1",
Expand All @@ -343,8 +342,8 @@
"dedent": "^0.7.0",
"delete-empty": "^2.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"enzyme-to-json": "^3.5.0",
"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 +359,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 @@ -438,7 +437,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 e15c939

Please sign in to comment.