Skip to content

Commit dce8b11

Browse files
authored
chore: linting updates (patw0929#384)
* chore: bump eslint, fixall * chore: bump lint-staged * chore: update eslint-loader
1 parent 18a3952 commit dce8b11

20 files changed

+816
-416
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
dist/**
2-
test/**
32
node_modules/*
43
package.json
54
webpack.*.js

.eslintrc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: ['eslint-config-airbnb', "plugin:prettier/recommended"],
2+
extends: ['eslint-config-airbnb', 'plugin:prettier/recommended'],
33
plugins: ['react', 'import', 'security', 'prettier'],
44
parser: 'babel-eslint',
55
env: {
@@ -75,12 +75,12 @@ module.exports = {
7575
],
7676
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
7777
},
78-
78+
7979
globals: {
8080
__DEVELOPMENT__: true,
8181
__CLIENT__: true,
8282
__SERVER__: true,
8383
__DISABLE_SSR__: true,
8484
__DEVTOOLS__: true,
8585
},
86-
};
86+
}

config/env.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
33
// injected into the application via DefinePlugin in Webpack configuration.
44

5-
const REACT_APP = /^REACT_APP_/i;
5+
const REACT_APP = /^REACT_APP_/i
66

77
/*
88
* Get Global Objects in different running environments
@@ -16,22 +16,22 @@ const getGlobalObject = () => `
1616
else
1717
return this;
1818
})()
19-
`;
19+
`
2020

2121
const getClientEnvironment = publicUrl => {
22-
const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development');
23-
const DEVELOPMENT = NODE_ENV === JSON.stringify('development');
24-
const SERVER = false;
25-
const CLIENT = true;
26-
const BUILD_NAME = JSON.stringify(process.env.BUILD_NAME || 'dev');
22+
const NODE_ENV = JSON.stringify(process.env.NODE_ENV || 'development')
23+
const DEVELOPMENT = NODE_ENV === JSON.stringify('development')
24+
const SERVER = false
25+
const CLIENT = true
26+
const BUILD_NAME = JSON.stringify(process.env.BUILD_NAME || 'dev')
2727

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

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

4949
return {
5050
'process.env': processEnv,
5151
getGlobalObject,
5252
__SERVER__: SERVER,
5353
__CLIENT__: CLIENT,
5454
__DEVELOPMENT__: DEVELOPMENT,
55-
};
56-
};
55+
}
56+
}
5757

58-
module.exports = getClientEnvironment;
58+
module.exports = getClientEnvironment

config/jest/cssTransform.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ module.exports = {
66
return `
77
const idObj = require('identity-obj-proxy');
88
module.exports = idObj;
9-
`;
9+
`
1010
},
1111
getCacheKey() {
1212
// eslint-disable-line no-unused-vars
1313
// The output is always the same.
14-
return 'cssTransform';
14+
return 'cssTransform'
1515
},
16-
};
16+
}

config/jest/fileTransform.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const path = require('path');
1+
const path = require('path')
22

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

66
module.exports = {
77
process(src, filename) {
88
// eslint-disable-next-line prefer-template
9-
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
9+
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'
1010
},
11-
};
11+
}

config/jest/setup.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import jsdom from 'jsdom';
2-
import sinon from 'sinon';
3-
import Enzyme from 'enzyme';
4-
import Adapter from 'enzyme-adapter-react-16';
5-
import '@babel/polyfill';
1+
import jsdom from 'jsdom'
2+
import sinon from 'sinon'
3+
import Enzyme from 'enzyme'
4+
import Adapter from 'enzyme-adapter-react-16'
5+
import '@babel/polyfill'
66

7-
Enzyme.configure({ adapter: new Adapter() });
7+
Enzyme.configure({ adapter: new Adapter() })
88

99
// localStorage
1010
class LocalStorageMock {
1111
constructor() {
12-
this.store = {};
12+
this.store = {}
1313
}
1414

1515
clear() {
16-
this.store = {};
16+
this.store = {}
1717
}
1818

1919
getItem(key) {
20-
return this.store[key];
20+
return this.store[key]
2121
}
2222

2323
setItem(key, value) {
24-
this.store[key] = value.toString();
24+
this.store[key] = value.toString()
2525
}
2626
}
2727

28-
window.localStorage = new LocalStorageMock();
29-
window.__SERVER__ = false;
30-
window.__DEVELOPMENT__ = false;
28+
window.localStorage = new LocalStorageMock()
29+
window.__SERVER__ = false
30+
window.__DEVELOPMENT__ = false
3131

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

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

4040
// Set up a mock window
41-
global.window = document.defaultView;
41+
global.window = document.defaultView
4242

4343
// Allow for things like window.location
44-
global.navigator = window.navigator;
44+
global.navigator = window.navigator
4545

46-
global.XMLHttpRequest = sinon.useFakeXMLHttpRequest();
46+
global.XMLHttpRequest = sinon.useFakeXMLHttpRequest()

config/jest/setupTestFramework.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* global jasmine:false */
22

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

10-
jasmine.getEnv().addReporter(junitReporter);
10+
jasmine.getEnv().addReporter(junitReporter)
1111
}

config/jest/transform.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const babelJest = require('babel-jest');
1+
const babelJest = require('babel-jest')
22

3-
module.exports = babelJest.createTransformer();
3+
module.exports = babelJest.createTransformer()

config/paths.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
var path = require('path');
2-
var fs = require('fs');
1+
var path = require('path')
2+
var fs = require('fs')
33

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

88
function resolveApp(relativePath) {
9-
return path.resolve(appDirectory, relativePath);
9+
return path.resolve(appDirectory, relativePath)
1010
}
1111

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

3434
// config after eject: we're in ./config/
3535
module.exports = {
3636
appDist: resolveApp('dist'),
3737
appPackageJson: resolveApp('package.json'),
3838
appSrc: resolveApp('src'),
3939
nodePaths: nodePaths,
40-
};
40+
}

package.json

+9-11
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"dotenv": "^4.0.0",
7373
"enzyme": "^3.3.0",
7474
"enzyme-adapter-react-16": "^1.5.0",
75-
"eslint": "^5.3.0",
75+
"eslint": "^7.32.0",
7676
"eslint-config-airbnb": "~17.1.0",
7777
"eslint-config-airbnb-base": "~13.1.0",
7878
"eslint-config-prettier": "^6.10.0",
@@ -90,7 +90,7 @@
9090
"jasmine-reporters": "^2.2.0",
9191
"jest": "^23.6.0",
9292
"jsdom": "^9.2.1",
93-
"lint-staged": "^3.2.6",
93+
"lint-staged": "^11.1.1",
9494
"mini-css-extract-plugin": "^0.4.5",
9595
"optimize-css-assets-webpack-plugin": "^5.0.1",
9696
"packwatch": "^1.0.0",
@@ -127,14 +127,12 @@
127127
"lint:commits": "yarn commitlint --from HEAD --to HEAD --verbose"
128128
},
129129
"lint-staged": {
130-
"linters": {
131-
"*.js": [
132-
"yarn eslint --"
133-
],
134-
"src/**/*.js": [
135-
"yarn run test -- --bail --findRelatedTests"
136-
]
137-
}
130+
"*.js": [
131+
"yarn eslint --"
132+
],
133+
"src/**/*.js": [
134+
"yarn run test -- --bail --findRelatedTests"
135+
]
138136
},
139137
"husky": {
140138
"hooks": {
@@ -146,7 +144,7 @@
146144
"semi": false,
147145
"printWidth": 80,
148146
"singleQuote": true,
149-
"trailingComma": "es5"
147+
"trailingComma": "all"
150148
},
151149
"engines": {
152150
"node": ">=6.14.14"

src/components/AllCountries.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ function _formatCountriesData(countriesData) {
357357

358358
function initialize(externalCountriesList) {
359359
countries = _formatCountriesData(
360-
externalCountriesList || defaultCountriesData
360+
externalCountriesList || defaultCountriesData,
361361
)
362362
}
363363

0 commit comments

Comments
 (0)