@reactunity/scripts 0.6.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.
- package/bin/react-unity-scripts.js +2 -2
- package/config/eslintConfig.js +46 -0
- package/config/modules.js +14 -0
- package/config/webpack.config.js +5 -54
- package/lib/types/base.d.ts +8 -5
- package/package.json +17 -19
- package/scripts/init.js +1 -0
- package/scripts/lint.js +39 -0
|
@@ -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
|
|
package/config/webpack.config.js
CHANGED
|
@@ -19,6 +19,7 @@ const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeM
|
|
|
19
19
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
20
20
|
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
|
21
21
|
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
22
|
+
const eslintConfig = require('./eslintConfig');
|
|
22
23
|
const paths = require('./paths');
|
|
23
24
|
const modules = require('./modules');
|
|
24
25
|
const getClientEnvironment = require('./env');
|
|
@@ -31,6 +32,7 @@ const restrictedGlobals = require('confusing-browser-globals');
|
|
|
31
32
|
const getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
|
|
32
33
|
// @remove-on-eject-end
|
|
33
34
|
|
|
35
|
+
|
|
34
36
|
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
|
35
37
|
const sourceMapVar = process.env.GENERATE_SOURCEMAP;
|
|
36
38
|
const shouldUseSourceMap = sourceMapVar !== 'false' && !!sourceMapVar;
|
|
@@ -58,19 +60,6 @@ const cssModuleRegex = /\.module\.css$/;
|
|
|
58
60
|
const sassRegex = /\.(scss|sass)$/;
|
|
59
61
|
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
|
60
62
|
|
|
61
|
-
const hasJsxRuntime = (() => {
|
|
62
|
-
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
require.resolve('react/jsx-runtime');
|
|
68
|
-
return true;
|
|
69
|
-
} catch (e) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
})();
|
|
73
|
-
|
|
74
63
|
// This is the production and development configuration.
|
|
75
64
|
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
|
76
65
|
module.exports = function (webpackEnv) {
|
|
@@ -316,7 +305,7 @@ module.exports = function (webpackEnv) {
|
|
|
316
305
|
[
|
|
317
306
|
require.resolve('babel-preset-react-app'),
|
|
318
307
|
{
|
|
319
|
-
runtime: hasJsxRuntime ? 'automatic' : 'classic',
|
|
308
|
+
runtime: modules.hasJsxRuntime ? 'automatic' : 'classic',
|
|
320
309
|
absoluteRuntime: false,
|
|
321
310
|
},
|
|
322
311
|
],
|
|
@@ -494,7 +483,7 @@ module.exports = function (webpackEnv) {
|
|
|
494
483
|
loader: require.resolve('file-loader'),
|
|
495
484
|
// Exclude `js` files to keep "css" loader working as it injects
|
|
496
485
|
// its runtime that would otherwise be processed through "file" loader.
|
|
497
|
-
// Also exclude `
|
|
486
|
+
// Also exclude `json` extensions so they get processed
|
|
498
487
|
// by webpacks internal loaders.
|
|
499
488
|
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.json$/],
|
|
500
489
|
options: {
|
|
@@ -586,49 +575,11 @@ module.exports = function (webpackEnv) {
|
|
|
586
575
|
}),
|
|
587
576
|
!disableESLintPlugin &&
|
|
588
577
|
new ESLintPlugin({
|
|
589
|
-
// Plugin options
|
|
590
|
-
extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
|
|
591
578
|
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
|
592
579
|
eslintPath: require.resolve('eslint'),
|
|
593
580
|
failOnError: !(isEnvDevelopment && emitErrorsAsWarnings),
|
|
594
581
|
context: paths.appSrc,
|
|
595
|
-
|
|
596
|
-
cacheLocation: path.resolve(
|
|
597
|
-
paths.appNodeModules,
|
|
598
|
-
'.cache/.eslintcache'
|
|
599
|
-
),
|
|
600
|
-
// ESLint class options
|
|
601
|
-
cwd: paths.appPath,
|
|
602
|
-
resolvePluginsRelativeTo: __dirname,
|
|
603
|
-
baseConfig: {
|
|
604
|
-
extends: [require.resolve('eslint-config-react-app')],
|
|
605
|
-
rules: {
|
|
606
|
-
...(!hasJsxRuntime && {
|
|
607
|
-
'react/react-in-jsx-scope': 'error',
|
|
608
|
-
}),
|
|
609
|
-
|
|
610
|
-
// Disable jsx-ally as it is irrelevant for us
|
|
611
|
-
// https://github.com/evcohen/eslint-plugin-jsx-a11y/tree/master/docs/rules
|
|
612
|
-
'jsx-a11y/alt-text': 'off',
|
|
613
|
-
'jsx-a11y/anchor-has-content': 'off',
|
|
614
|
-
'jsx-a11y/anchor-is-valid': 'off',
|
|
615
|
-
'jsx-a11y/aria-activedescendant-has-tabindex': 'off',
|
|
616
|
-
'jsx-a11y/aria-props': 'off',
|
|
617
|
-
'jsx-a11y/aria-proptypes': 'off',
|
|
618
|
-
'jsx-a11y/aria-role': 'off',
|
|
619
|
-
'jsx-a11y/aria-unsupported-elements': 'off',
|
|
620
|
-
'jsx-a11y/heading-has-content': 'off',
|
|
621
|
-
'jsx-a11y/iframe-has-title': 'off',
|
|
622
|
-
'jsx-a11y/img-redundant-alt': 'off',
|
|
623
|
-
'jsx-a11y/no-access-key': 'off',
|
|
624
|
-
'jsx-a11y/no-distracting-elements': 'off',
|
|
625
|
-
'jsx-a11y/no-redundant-roles': 'off',
|
|
626
|
-
'jsx-a11y/role-has-required-aria-props': 'off',
|
|
627
|
-
'jsx-a11y/role-supports-aria-props': 'off',
|
|
628
|
-
'jsx-a11y/scope': 'off',
|
|
629
|
-
'no-restricted-globals': ['error'].concat(restrictedGlobals.filter(x => x !== 'location')),
|
|
630
|
-
},
|
|
631
|
-
},
|
|
582
|
+
...eslintConfig,
|
|
632
583
|
}),
|
|
633
584
|
].filter(Boolean),
|
|
634
585
|
// Turn off performance processing because we utilize
|
package/lib/types/base.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
/// <reference
|
|
1
|
+
/// <reference no-default-lib="true"/>
|
|
2
|
+
/// <reference lib="es2021" />
|
|
2
3
|
/// <reference types="react" />
|
|
3
|
-
/// <reference types="
|
|
4
|
-
/// <reference types="chai" />
|
|
5
|
-
|
|
6
|
-
declare var expect: Chai.ExpectStatic;
|
|
4
|
+
/// <reference types="webpack-env" />
|
|
7
5
|
|
|
8
6
|
declare namespace NodeJS {
|
|
9
7
|
interface ProcessEnv {
|
|
@@ -67,6 +65,11 @@ declare module '*.txt' {
|
|
|
67
65
|
export default value;
|
|
68
66
|
}
|
|
69
67
|
|
|
68
|
+
declare module '*.html' {
|
|
69
|
+
const value: string;
|
|
70
|
+
export default value;
|
|
71
|
+
}
|
|
72
|
+
|
|
70
73
|
declare module '!!raw-loader!*' {
|
|
71
74
|
const value: string;
|
|
72
75
|
export default value;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reactunity/scripts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Configuration and scripts for React Unity.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"preinstall": "npx only-allow@1.0.0 yarn"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@babel/core": "7.15.
|
|
50
|
+
"@babel/core": "7.15.8",
|
|
51
51
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
|
|
52
|
-
"@types/react": "^17.0.
|
|
53
|
-
"@types/webpack-env": "1.16.
|
|
54
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
55
|
-
"@typescript-eslint/parser": "^
|
|
52
|
+
"@types/react": "^17.0.30",
|
|
53
|
+
"@types/webpack-env": "1.16.3",
|
|
54
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
55
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
56
56
|
"babel-eslint": "^10.1.0",
|
|
57
57
|
"babel-loader": "8.2.2",
|
|
58
58
|
"babel-plugin-named-asset-import": "^0.3.7",
|
|
@@ -61,15 +61,13 @@
|
|
|
61
61
|
"camelcase": "^6.2.0",
|
|
62
62
|
"case-sensitive-paths-webpack-plugin": "2.4.0",
|
|
63
63
|
"confusing-browser-globals": "^1.0.10",
|
|
64
|
-
"css-loader": "6.
|
|
64
|
+
"css-loader": "6.4.0",
|
|
65
65
|
"dotenv": "10.0.0",
|
|
66
66
|
"dotenv-expand": "5.1.0",
|
|
67
67
|
"eslint": "^7.32.0",
|
|
68
68
|
"eslint-config-react-app": "^6.0.0",
|
|
69
|
-
"eslint-plugin-
|
|
70
|
-
"eslint-plugin-
|
|
71
|
-
"eslint-plugin-jsx-a11y": "6.4.1",
|
|
72
|
-
"eslint-plugin-react": "^7.26.0",
|
|
69
|
+
"eslint-plugin-import": "^2.25.2",
|
|
70
|
+
"eslint-plugin-react": "^7.26.1",
|
|
73
71
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
74
72
|
"eslint-plugin-testing-library": "^4.12.4",
|
|
75
73
|
"eslint-webpack-plugin": "^3.0.1",
|
|
@@ -78,33 +76,33 @@
|
|
|
78
76
|
"identity-obj-proxy": "3.0.0",
|
|
79
77
|
"null-loader": "^4.0.1",
|
|
80
78
|
"pnp-webpack-plugin": "1.7.0",
|
|
81
|
-
"prompts": "2.4.
|
|
79
|
+
"prompts": "2.4.2",
|
|
82
80
|
"raw-loader": "^4.0.2",
|
|
83
81
|
"react-app-polyfill": "^2.0.0",
|
|
84
82
|
"react-dev-utils": "https://github.com/ReactUnity/scripts/raw/main/temp/react-dev-utils-11.0.3-hotfix.tgz",
|
|
85
83
|
"react-refresh": "^0.10.0",
|
|
86
84
|
"resolve": "1.20.0",
|
|
87
85
|
"resolve-url-loader": "^4.0.0",
|
|
88
|
-
"sass-loader": "^12.
|
|
86
|
+
"sass-loader": "^12.2.0",
|
|
89
87
|
"semver": "7.3.5",
|
|
90
88
|
"style-loader": "3.3.0",
|
|
91
89
|
"terser-webpack-plugin": "5.2.4",
|
|
92
90
|
"ts-pnp": "1.2.0",
|
|
93
91
|
"url-loader": "4.1.1",
|
|
94
|
-
"webpack": "5.
|
|
95
|
-
"webpack-dev-server": "4.
|
|
92
|
+
"webpack": "5.58.2",
|
|
93
|
+
"webpack-dev-server": "4.3.1"
|
|
96
94
|
},
|
|
97
95
|
"devDependencies": {
|
|
98
96
|
"react": "^17.0.2",
|
|
99
|
-
"typescript": "^4.4.
|
|
97
|
+
"typescript": "^4.4.4"
|
|
100
98
|
},
|
|
101
99
|
"optionalDependencies": {
|
|
102
100
|
"fsevents": "^2.3.2",
|
|
103
|
-
"sass": "^1.
|
|
101
|
+
"sass": "^1.43.2"
|
|
104
102
|
},
|
|
105
103
|
"peerDependencies": {
|
|
106
|
-
"@reactunity/renderer": "^0.
|
|
107
|
-
"typescript": "^4.4.
|
|
104
|
+
"@reactunity/renderer": "^0.7.0",
|
|
105
|
+
"typescript": "^4.4.4"
|
|
108
106
|
},
|
|
109
107
|
"peerDependenciesMeta": {
|
|
110
108
|
"typescript": {
|
package/scripts/init.js
CHANGED
package/scripts/lint.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
// Do this as the first thing so that any code reading it knows the right env.
|
|
12
|
+
process.env.BABEL_ENV = process.env.BABEL_ENV || process.env.NODE_ENV || 'development';
|
|
13
|
+
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
14
|
+
|
|
15
|
+
// Makes the script crash on unhandled rejections instead of silently
|
|
16
|
+
// ignoring them. In the future, promise rejections that are not handled will
|
|
17
|
+
// terminate the Node.js process with a non-zero exit code.
|
|
18
|
+
process.on('unhandledRejection', err => {
|
|
19
|
+
throw err;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Ensure environment variables are read.
|
|
23
|
+
require('../config/env');
|
|
24
|
+
|
|
25
|
+
const paths = require('../config/paths');
|
|
26
|
+
const eslintConfig = require('../config/eslintConfig');
|
|
27
|
+
const formatter = require('react-dev-utils/eslintFormatter');
|
|
28
|
+
|
|
29
|
+
const { ESLint } = require("eslint");
|
|
30
|
+
|
|
31
|
+
(async function main() {
|
|
32
|
+
const eslint = new ESLint(eslintConfig);
|
|
33
|
+
const results = await eslint.lintFiles([paths.appSrc]);
|
|
34
|
+
const resultText = formatter(results);
|
|
35
|
+
console.log(resultText);
|
|
36
|
+
})().catch((error) => {
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
console.error(error);
|
|
39
|
+
});
|