Skip to content

Commit

Permalink
Merge 04bf8b0 into 18a3952
Browse files Browse the repository at this point in the history
  • Loading branch information
mcataford committed Aug 4, 2021
2 parents 18a3952 + 04bf8b0 commit 842851f
Show file tree
Hide file tree
Showing 20 changed files with 772 additions and 395 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
dist/**
test/**
node_modules/*
package.json
webpack.*.js
Expand Down
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['eslint-config-airbnb', "plugin:prettier/recommended"],
extends: ['eslint-config-airbnb', 'plugin:prettier/recommended'],
plugins: ['react', 'import', 'security', 'prettier'],
parser: 'babel-eslint',
env: {
Expand Down Expand Up @@ -75,12 +75,12 @@ module.exports = {
],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
},

globals: {
__DEVELOPMENT__: true,
__CLIENT__: true,
__SERVER__: true,
__DISABLE_SSR__: true,
__DEVTOOLS__: true,
},
};
}
28 changes: 14 additions & 14 deletions config/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
// injected into the application via DefinePlugin in Webpack configuration.

const REACT_APP = /^REACT_APP_/i;
const REACT_APP = /^REACT_APP_/i

/*
* Get Global Objects in different running environments
Expand All @@ -16,22 +16,22 @@ const getGlobalObject = () => `
else
return this;
})()
`;
`

const getClientEnvironment = publicUrl => {
const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
const DEVELOPMENT = NODE_ENV === JSON.stringify('development');
const SERVER = false;
const CLIENT = true;
const BUILD_NAME = JSON.stringify(process.env.BUILD_NAME || 'dev');
const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development')
const DEVELOPMENT = NODE_ENV === JSON.stringify('development')
const SERVER = false
const CLIENT = true
const BUILD_NAME = JSON.stringify(process.env.BUILD_NAME || 'dev')

const processEnv = Object.keys(process.env)
.filter(key => REACT_APP.test(key))
.reduce(
(env, key) => {
env[key] = JSON.stringify(process.env[key]); // eslint-disable-line no-param-reassign
env[key] = JSON.stringify(process.env[key]) // eslint-disable-line no-param-reassign

return env;
return env
},
{
// Useful for determining whether we’re running in production mode.
Expand All @@ -43,16 +43,16 @@ const getClientEnvironment = publicUrl => {
// images into the `src` and `import` them in code to get their paths.
PUBLIC_URL: JSON.stringify(publicUrl),
BUILD_NAME: BUILD_NAME,
}
);
},
)

return {
'process.env': processEnv,
getGlobalObject,
__SERVER__: SERVER,
__CLIENT__: CLIENT,
__DEVELOPMENT__: DEVELOPMENT,
};
};
}
}

module.exports = getClientEnvironment;
module.exports = getClientEnvironment
6 changes: 3 additions & 3 deletions config/jest/cssTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ module.exports = {
return `
const idObj = require('identity-obj-proxy');
module.exports = idObj;
`;
`
},
getCacheKey() {
// eslint-disable-line no-unused-vars
// The output is always the same.
return 'cssTransform';
return 'cssTransform'
},
};
}
6 changes: 3 additions & 3 deletions config/jest/fileTransform.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const path = require('path');
const path = require('path')

// This is a custom Jest transformer turning file imports into filenames.
// http://facebook.github.io/jest/docs/tutorial-webpack.html

module.exports = {
process(src, filename) {
// eslint-disable-next-line prefer-template
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'
},
};
}
36 changes: 18 additions & 18 deletions config/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
import jsdom from 'jsdom';
import sinon from 'sinon';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import '@babel/polyfill';
import jsdom from 'jsdom'
import sinon from 'sinon'
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import '@babel/polyfill'

Enzyme.configure({ adapter: new Adapter() });
Enzyme.configure({ adapter: new Adapter() })

// localStorage
class LocalStorageMock {
constructor() {
this.store = {};
this.store = {}
}

clear() {
this.store = {};
this.store = {}
}

getItem(key) {
return this.store[key];
return this.store[key]
}

setItem(key, value) {
this.store[key] = value.toString();
this.store[key] = value.toString()
}
}

window.localStorage = new LocalStorageMock();
window.__SERVER__ = false;
window.__DEVELOPMENT__ = false;
window.localStorage = new LocalStorageMock()
window.__SERVER__ = false
window.__DEVELOPMENT__ = false

// Define some html to be our basic document
// JSDOM will consume this and act as if we were in a browser
const DEFAULT_HTML = '<!doctype html><html><body></body></html>';
const DEFAULT_HTML = '<!doctype html><html><body></body></html>'

// Define some variables to make it look like we're a browser
// First, use JSDOM's fake DOM as the document
global.document = jsdom.jsdom(DEFAULT_HTML);
global.document = jsdom.jsdom(DEFAULT_HTML)

// Set up a mock window
global.window = document.defaultView;
global.window = document.defaultView

// Allow for things like window.location
global.navigator = window.navigator;
global.navigator = window.navigator

global.XMLHttpRequest = sinon.useFakeXMLHttpRequest();
global.XMLHttpRequest = sinon.useFakeXMLHttpRequest()
6 changes: 3 additions & 3 deletions config/jest/setupTestFramework.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* global jasmine:false */

if (process.env.CI) {
const jasmineReporters = require('jasmine-reporters'); // eslint-disable-line global-require
const jasmineReporters = require('jasmine-reporters') // eslint-disable-line global-require
const junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: 'testresults',
consolidateAll: false,
});
})

jasmine.getEnv().addReporter(junitReporter);
jasmine.getEnv().addReporter(junitReporter)
}
4 changes: 2 additions & 2 deletions config/jest/transform.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const babelJest = require('babel-jest');
const babelJest = require('babel-jest')

module.exports = babelJest.createTransformer();
module.exports = babelJest.createTransformer()
12 changes: 6 additions & 6 deletions config/paths.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var path = require('path');
var fs = require('fs');
var path = require('path')
var fs = require('fs')

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const appDirectory = fs.realpathSync(process.cwd())

function resolveApp(relativePath) {
return path.resolve(appDirectory, relativePath);
return path.resolve(appDirectory, relativePath)
}

// We support resolving modules according to `NODE_PATH`.
Expand All @@ -29,12 +29,12 @@ const nodePaths = (process.env.NODE_PATH || '')
.split(process.platform === 'win32' ? ';' : ':')
.filter(Boolean)
.filter(folder => !path.isAbsolute(folder))
.map(resolveApp);
.map(resolveApp)

// config after eject: we're in ./config/
module.exports = {
appDist: resolveApp('dist'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('src'),
nodePaths: nodePaths,
};
}
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"dotenv": "^4.0.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.5.0",
"eslint": "^5.3.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "~17.1.0",
"eslint-config-airbnb-base": "~13.1.0",
"eslint-config-prettier": "^6.10.0",
Expand All @@ -90,7 +90,7 @@
"jasmine-reporters": "^2.2.0",
"jest": "^23.6.0",
"jsdom": "^9.2.1",
"lint-staged": "^3.2.6",
"lint-staged": "^11.1.1",
"mini-css-extract-plugin": "^0.4.5",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"packwatch": "^1.0.0",
Expand Down Expand Up @@ -127,14 +127,12 @@
"lint:commits": "yarn commitlint --from HEAD --to HEAD --verbose"
},
"lint-staged": {
"linters": {
"*.js": [
"yarn eslint --"
],
"src/**/*.js": [
"yarn run test -- --bail --findRelatedTests"
]
}
},
"husky": {
"hooks": {
Expand All @@ -146,7 +144,7 @@
"semi": false,
"printWidth": 80,
"singleQuote": true,
"trailingComma": "es5"
"trailingComma": "all"
},
"engines": {
"node": ">=6.14.14"
Expand Down
2 changes: 1 addition & 1 deletion src/components/AllCountries.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ function _formatCountriesData(countriesData) {

function initialize(externalCountriesList) {
countries = _formatCountriesData(
externalCountriesList || defaultCountriesData
externalCountriesList || defaultCountriesData,
)
}

Expand Down
Loading

0 comments on commit 842851f

Please sign in to comment.