Skip to content

Commit

Permalink
Merge pull request #5 from IronTony/development
Browse files Browse the repository at this point in the history
Chore deps + some fixes and refactor
Linter fixes
  • Loading branch information
IronTony authored Oct 19, 2021
2 parents 8ca12ec + 97f0520 commit 4e3af8a
Show file tree
Hide file tree
Showing 24 changed files with 304 additions and 238 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint:staged && yarn dependencies:checkCircular && yarn dependencies:graph
yarn run pre-commit
16 changes: 9 additions & 7 deletions config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ delete require.cache[require.resolve('./paths')];

const NODE_ENV = process.env.NODE_ENV;
if (!NODE_ENV) {
throw new Error('The NODE_ENV environment variable is required but was not specified.');
throw new Error(
'The NODE_ENV environment variable is required but was not specified.'
);
}

// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
Expand All @@ -28,12 +30,12 @@ const dotenvFiles = [
// that have already been set. Variable expansion is supported in .env files.
// https://github.com/motdotla/dotenv
// https://github.com/motdotla/dotenv-expand
dotenvFiles.forEach((dotenvFile) => {
dotenvFiles.forEach(dotenvFile => {
if (fs.existsSync(dotenvFile)) {
require('dotenv-expand')(
require('dotenv').config({
path: dotenvFile,
}),
})
);
}
});
Expand All @@ -50,8 +52,8 @@ dotenvFiles.forEach((dotenvFile) => {
const appDirectory = fs.realpathSync(process.cwd());
process.env.NODE_PATH = (process.env.NODE_PATH || '')
.split(path.delimiter)
.filter((folder) => folder && !path.isAbsolute(folder))
.map((folder) => path.resolve(appDirectory, folder))
.filter(folder => folder && !path.isAbsolute(folder))
.map(folder => path.resolve(appDirectory, folder))
.join(path.delimiter);

// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
Expand All @@ -60,7 +62,7 @@ const REACT_APP = /^REACT_APP_/i;

function getClientEnvironment(publicUrl) {
const raw = Object.keys(process.env)
.filter((key) => REACT_APP.test(key))
.filter(key => REACT_APP.test(key))
.reduce(
(env, key) => {
env[key] = process.env[key];
Expand Down Expand Up @@ -88,7 +90,7 @@ function getClientEnvironment(publicUrl) {
// which is why it's disabled by default.
// It is defined here so it is available in the webpackHotDevClient.
FAST_REFRESH: process.env.FAST_REFRESH !== 'false',
},
}
);
// Stringify all values so we can feed into webpack DefinePlugin
const stringified = {
Expand Down
6 changes: 3 additions & 3 deletions config/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function getAdditionalModulePaths(options = {}) {
throw new Error(
chalk.red.bold(
"Your project's `baseUrl` can only be set to `src` or `node_modules`." +
' Create React App does not support other values at this time.',
),
' Create React App does not support other values at this time.'
)
);
}

Expand Down Expand Up @@ -98,7 +98,7 @@ function getModules() {

if (hasTsConfig && hasJsConfig) {
throw new Error(
'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.',
'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
);
}

Expand Down
10 changes: 7 additions & 3 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');
// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);

// We use `PUBLIC_URL` environment variable or "homepage" field to infer
// "public path" at which the app is served.
Expand All @@ -18,7 +18,7 @@ const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);
const publicUrlOrPath = getPublicUrlOrPath(
process.env.NODE_ENV === 'development',
require(resolveApp('package.json')).homepage,
process.env.PUBLIC_URL,
process.env.PUBLIC_URL
);

const buildPath = process.env.BUILD_PATH || 'build';
Expand All @@ -39,7 +39,9 @@ const moduleFileExtensions = [

// Resolve file paths in the same order as webpack
const resolveModule = (resolveFn, filePath) => {
const extension = moduleFileExtensions.find((extension) => fs.existsSync(resolveFn(`${filePath}.${extension}`)));
const extension = moduleFileExtensions.find(extension =>
fs.existsSync(resolveFn(`${filePath}.${extension}`))
);

if (extension) {
return resolveFn(`${filePath}.${extension}`);
Expand Down Expand Up @@ -68,4 +70,6 @@ module.exports = {
publicUrlOrPath,
};



module.exports.moduleFileExtensions = moduleFileExtensions;
Loading

0 comments on commit 4e3af8a

Please sign in to comment.