@reactunity/scripts 0.4.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,12 +19,12 @@ const spawn = require('react-dev-utils/crossSpawn');
19
19
  const args = process.argv.slice(2);
20
20
 
21
21
  const scriptIndex = args.findIndex(
22
- x => x === 'build' || x === 'eject' || x === 'start' || x === 'test'
22
+ x => x === 'build' || x === 'eject' || x === 'start' || x === 'test' || x === 'lint'
23
23
  );
24
24
  const script = scriptIndex === -1 ? args[0] : args[scriptIndex];
25
25
  const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : [];
26
26
 
27
- if (['build', 'eject', 'start', 'test'].includes(script)) {
27
+ if (['build', 'eject', 'start', 'test', 'lint'].includes(script)) {
28
28
  const result = spawn.sync(
29
29
  process.execPath,
30
30
  nodeArgs
@@ -0,0 +1,46 @@
1
+ // @remove-on-eject-begin
2
+ /**
3
+ * Copyright (c) 2015-present, Facebook, Inc.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ // @remove-on-eject-end
9
+ 'use strict';
10
+
11
+ const path = require('path');
12
+ const baseEslintConfig = require('eslint-config-react-app');
13
+ const restrictedGlobals = require('confusing-browser-globals');
14
+ const paths = require('./paths');
15
+ const modules = require('./modules');
16
+
17
+ const baseEslintConfigRules = {};
18
+ for (const key in baseEslintConfig.rules) {
19
+ if (Object.hasOwnProperty.call(baseEslintConfig.rules, key) && !key.startsWith('flowtype') && !key.startsWith('jsx-a11y')) {
20
+ baseEslintConfigRules[key] = baseEslintConfig.rules[key];
21
+ }
22
+ }
23
+
24
+ const baseConfig = {
25
+ ...baseEslintConfig,
26
+ plugins: ['import', 'react-hooks'],
27
+ rules: {
28
+ ...baseEslintConfigRules,
29
+ ...(!modules.hasJsxRuntime && {
30
+ 'react/react-in-jsx-scope': 'error',
31
+ }),
32
+ 'no-restricted-globals': ['error'].concat(restrictedGlobals.filter(x => x !== 'location')),
33
+ },
34
+ };
35
+
36
+ module.exports = {
37
+ extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
38
+ cache: true,
39
+ cacheLocation: path.resolve(
40
+ paths.appNodeModules,
41
+ '.cache/.eslintcache'
42
+ ),
43
+ cwd: paths.appPath,
44
+ resolvePluginsRelativeTo: __dirname,
45
+ baseConfig,
46
+ };
package/config/modules.js CHANGED
@@ -131,11 +131,25 @@ function getModules() {
131
131
 
132
132
  const additionalModulePaths = getAdditionalModulePaths(options);
133
133
 
134
+ const hasJsxRuntime = (() => {
135
+ if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
136
+ return false;
137
+ }
138
+
139
+ try {
140
+ require.resolve('react/jsx-runtime');
141
+ return true;
142
+ } catch (e) {
143
+ return false;
144
+ }
145
+ })();
146
+
134
147
  return {
135
148
  additionalModulePaths: additionalModulePaths,
136
149
  webpackAliases: getWebpackAliases(options),
137
150
  jestAliases: getJestAliases(options),
138
151
  hasTsConfig,
152
+ hasJsxRuntime,
139
153
  };
140
154
  }
141
155