Skip to content

Commit 48e25fc

Browse files
committed
chore: add eslint and fix errors
1 parent 478830c commit 48e25fc

File tree

4 files changed

+588
-47
lines changed

4 files changed

+588
-47
lines changed

.eslintrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"settings": { "react": { "version": "detect" } },
3+
"parser": "babel-eslint",
4+
"extends": ["plugin:react/recommended", "plugin:prettier/recommended"]
5+
}

package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
"repository": "hudovisk/react-optimize",
66
"license": "MIT",
77
"scripts": {
8+
"lint:fix": "yarn lint --fix",
9+
"lint": "eslint src/ test/",
810
"test:node": "mocha --require @babel/register test/test.node.js",
911
"test:browser": "cross-env NODE_ENV=test karma start",
10-
"test": "yarn run test:node && yarn run test:browser",
12+
"test": "yarn run test:node && yarn run test:browser && yarn run lint",
1113
"build": "webpack",
1214
"watch": "webpack --watch",
1315
"prepublishOnly": "yarn run build"
1416
},
1517
"husky": {
1618
"hooks": {
17-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
19+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
20+
"pre-commit": "yarn run lint"
1821
}
1922
},
2023
"devDependencies": {
@@ -26,11 +29,16 @@
2629
"@babel/register": "^7.4.0",
2730
"@commitlint/cli": "^8.2.0",
2831
"@commitlint/config-conventional": "^8.2.0",
32+
"babel-eslint": "^10.0.3",
2933
"babel-loader": "^8.0.4",
3034
"chai": "^4.2.0",
3135
"cross-env": "^6.0.3",
3236
"enzyme": "^3.9.0",
3337
"enzyme-adapter-react-16": "^1.12.1",
38+
"eslint": "^6.7.2",
39+
"eslint-config-prettier": "^6.7.0",
40+
"eslint-plugin-prettier": "^3.1.1",
41+
"eslint-plugin-react": "^7.17.0",
3442
"husky": "^3.1.0",
3543
"karma": "^4.1.0",
3644
"karma-chrome-launcher": "^3.1.0",
@@ -40,6 +48,7 @@
4048
"karma-sourcemap-loader": "^0.3.7",
4149
"karma-webpack": "^4.0.2",
4250
"mocha": "^6.1.3",
51+
"prettier": "^1.19.1",
4352
"react": "^16.8.6",
4453
"react-dom": "^16.8.6",
4554
"semantic-release": "^15.13.3",

src/Experiment.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ class Experiment extends React.Component {
4747
this.delayedInitialization();
4848
}
4949

50-
window.gtag && window.gtag("event", "optimize.callback", {
51-
name: this.props.id,
52-
callback: this.updateVariant
53-
});
50+
window.gtag &&
51+
window.gtag("event", "optimize.callback", {
52+
name: this.props.id,
53+
callback: this.updateVariant
54+
});
5455
}
5556

5657
componentWillUnmount() {
57-
window.gtag && window.gtag("event", "optimize.callback", {
58-
name: this.props.id,
59-
callback: this.updateVariant,
60-
remove: true
61-
});
58+
window.gtag &&
59+
window.gtag("event", "optimize.callback", {
60+
name: this.props.id,
61+
callback: this.updateVariant,
62+
remove: true
63+
});
6264
}
6365

6466
render() {
@@ -70,4 +72,4 @@ class Experiment extends React.Component {
7072
}
7173
}
7274

73-
export default Experiment;
75+
export default Experiment;

0 commit comments

Comments
 (0)