From f0b31599d04c2630d93d0c22e4b7c67b635d39fb Mon Sep 17 00:00:00 2001 From: Alex Page Date: Mon, 13 Mar 2023 21:10:48 +1100 Subject: [PATCH] Config for runtime: automatic --- .eslintrc.js | 6 +++++- babel.config.js | 12 ++++++++++-- polaris-migrator/tsconfig.json | 2 +- polaris-react/tsconfig.json | 3 ++- polaris.shopify.com/tsconfig.json | 2 +- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 04a187a2e2f..209ca364852 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -55,6 +55,11 @@ module.exports = { 'react/button-has-type': 'off', 'react/no-array-index-key': 'off', 'react/no-unsafe': ['error', {checkAliases: true}], + + // These can be removed when eslint-plugin-react is updated + 'react/jsx-uses-react': 'off', + 'react/react-in-jsx-scope': 'off', + '@shopify/jsx-no-complex-expressions': 'off', '@shopify/jsx-prefer-fragment-wrappers': 'off', '@shopify/no-ancestor-directory-import': 'error', @@ -165,7 +170,6 @@ module.exports = { files: ['polaris.shopify.com/**/*'], extends: 'plugin:@next/eslint-plugin-next/recommended', rules: { - 'react/react-in-jsx-scope': 'off', '@shopify/jsx-no-hardcoded-content': 'off', 'import/no-default-export': 'off', }, diff --git a/babel.config.js b/babel.config.js index 7793d0d463c..d8e21a6a18a 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,7 +1,9 @@ /** * @type {import('@babel/core').TransformOptions} */ -module.exports = function () { +module.exports = function (api) { + api.cache(true); + return { presets: [ [ @@ -9,7 +11,13 @@ module.exports = function () { {useBuiltIns: 'entry', corejs: '3.0', bugfixes: true}, ], ['@babel/preset-typescript'], - ['@babel/preset-react', {runtime: 'automatic', useBuiltIns: true}], + [ + '@babel/preset-react', + { + runtime: 'automatic', + useBuiltIns: true, + }, + ], ], assumptions: { setPublicClassFields: true, diff --git a/polaris-migrator/tsconfig.json b/polaris-migrator/tsconfig.json index 6051d2576fb..661fd5a6b96 100644 --- a/polaris-migrator/tsconfig.json +++ b/polaris-migrator/tsconfig.json @@ -6,7 +6,7 @@ "emitDeclarationOnly": true, "outDir": "dist/types", "rootDir": "src", - "jsx": "react", + "jsx": "react-jsx", "types": ["node", "jest"] }, "include": ["src"], diff --git a/polaris-react/tsconfig.json b/polaris-react/tsconfig.json index c317885ab27..3eb23ffb4d2 100644 --- a/polaris-react/tsconfig.json +++ b/polaris-react/tsconfig.json @@ -9,7 +9,8 @@ "strictFunctionTypes": false, "paths": { "tests/*": ["./tests/*"] - } + }, + "jsx": "react-jsx" }, "include": [ "./src", diff --git a/polaris.shopify.com/tsconfig.json b/polaris.shopify.com/tsconfig.json index 356f7512c1a..09c48e63393 100644 --- a/polaris.shopify.com/tsconfig.json +++ b/polaris.shopify.com/tsconfig.json @@ -15,7 +15,7 @@ "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, - "jsx": "preserve", + "jsx": "react-jsx", "composite": true, "noUnusedLocals": true, "noUnusedParameters": true