-
Notifications
You must be signed in to change notification settings - Fork 859
Allow as const syntax in tests #2733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
82ae587
8073945
e7ccdb0
e72357e
aa2b4cb
1c12f69
bad14c7
2e12aee
445951c
13462e9
d9101ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,10 @@ module.exports = { | |
| ] | ||
| }, | ||
| "useBuiltIns": process.env.NO_COREJS_POLYFILL ? false : "usage", | ||
| "corejs": "2", | ||
| "modules": process.env.BABEL_MODULES ? process.env.BABEL_MODULES : "commonjs" // babel's default is commonjs | ||
| }], | ||
| "@babel/typescript", | ||
| ["@babel/typescript", { isTSX: true, allExtensions: true }], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no longer a "good" way to hack this functionality into the ts->proptypes generation. |
||
| "@babel/react" | ||
| ], | ||
| "plugins": [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,10 +9,10 @@ | |
| "docker_image": "node:10", | ||
| "sideEffects": false, | ||
| "scripts": { | ||
| "start": "webpack-dev-server --port 8030 --inline --hot --config=src-docs/webpack.config.js", | ||
| "start": "BABEL_MODULES=false webpack-dev-server --port 8030 --inline --hot --config=src-docs/webpack.config.js", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the builds require |
||
| "test-docker": "docker pull $npm_package_docker_image && docker run --rm -i -e GIT_COMMITTER_NAME=test -e GIT_COMMITTER_EMAIL=test --user=$(id -u):$(id -g) -e HOME=/tmp -v $(pwd):/app -w /app $npm_package_docker_image bash -c 'npm config set spin false && /opt/yarn*/bin/yarn && npm run test && npm run build'", | ||
| "sync-docs": "node ./scripts/docs-sync.js", | ||
| "build-docs": "cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 webpack --config=src-docs/webpack.config.js", | ||
| "build-docs": "BABEL_MODULES=false cross-env NODE_ENV=production NODE_OPTIONS=--max-old-space-size=4096 webpack --config=src-docs/webpack.config.js", | ||
| "build": "yarn extract-i18n-strings && node ./scripts/compile-clean.js && node ./scripts/compile-eui.js && node ./scripts/compile-scss.js $npm_package_name", | ||
| "compile-icons": "node ./scripts/compile-icons.js && prettier --write --loglevel=warn \"./src/components/icon/assets/**/*.js\"", | ||
| "extract-i18n-strings": "node ./scripts/babel/fetch-i18n-strings", | ||
|
|
@@ -67,14 +67,14 @@ | |
| "uuid": "^3.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/cli": "^7.1.2", | ||
| "@babel/core": "^7.1.2", | ||
| "@babel/plugin-proposal-class-properties": "^7.1.0", | ||
| "@babel/plugin-proposal-object-rest-spread": "^7.0.0", | ||
| "@babel/plugin-syntax-dynamic-import": "^7.2.0", | ||
| "@babel/preset-env": "^7.1.0", | ||
| "@babel/preset-react": "^7.0.0", | ||
| "@babel/preset-typescript": "^7.1.0", | ||
| "@babel/cli": "^7.8.3", | ||
| "@babel/core": "^7.8.3", | ||
| "@babel/plugin-proposal-class-properties": "^7.8.3", | ||
| "@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
| "@babel/plugin-syntax-dynamic-import": "^7.8.3", | ||
| "@babel/preset-env": "^7.8.3", | ||
| "@babel/preset-react": "^7.8.3", | ||
| "@babel/preset-typescript": "^7.8.3", | ||
| "@elastic/charts": "^13.0.0", | ||
| "@elastic/datemath": "^5.0.2", | ||
| "@elastic/eslint-config-kibana": "^0.15.0", | ||
|
|
@@ -185,7 +185,7 @@ | |
| "wdio-spec-reporter": "^0.1.4", | ||
| "wdio-visual-regression-service": "silne30/wdio-visual-regression-service#Add_Filename_To_Result", | ||
| "webdriverio": "^4.12.0", | ||
| "webpack": "^4.23.1", | ||
| "webpack": "^4.41.5", | ||
| "webpack-cli": "^3.1.2", | ||
| "webpack-dev-server": "^3.1.14", | ||
| "yeoman-generator": "^2.0.1", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,7 +56,7 @@ function handleJSXPath(path) { | |
| function traverseFile(filepath) { | ||
| const source = fs.readFileSync(filepath); | ||
| const ast = babel.parse( | ||
| source, | ||
| source.toString(), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Buffers are no longer supported |
||
| { | ||
| ...babelOptions, | ||
| filename: basename(filepath), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ const webpackConfig = { | |
| { | ||
| test: /\.(js|tsx?)$/, | ||
| loaders: useCache(['babel-loader']), // eslint-disable-line react-hooks/rules-of-hooks | ||
| exclude: /node_modules/, | ||
| exclude: [/node_modules/, /packages\/react-datepicker/], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without excluding, babel's transform of react-datepicker's commonjs format conflicts with webpack processing files as ES Modules and everything breaks down. |
||
| }, | ||
| { | ||
| test: /\.scss$/, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { useEffect, useState, useRef } from 'react'; | |
| export function useDependentState<T>( | ||
| valueFn: (previousState: undefined | T) => T, | ||
| deps: unknown[] | ||
| ): [T, React.Dispatch<React.SetStateAction<T>>] { | ||
| ) { | ||
| const [state, setState] = useState<T>(valueFn as () => T); | ||
|
|
||
| // use ref instead of a state to avoid causing an unnecessary re-render | ||
|
|
@@ -22,5 +22,5 @@ export function useDependentState<T>( | |
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, deps); | ||
|
|
||
| return [state, setState]; | ||
| return [state, setState] as const; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the whole goal of this PR :) |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New requirement for babel's
envpreset so they can maintain compatibility in the future when the default version is changed to3.