Skip to content

Commit 665c932

Browse files
committed
Refactors using eslint
1 parent 695862a commit 665c932

File tree

6 files changed

+118
-8
lines changed

6 files changed

+118
-8
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm run lint
4+
npm run lint:ws

config/.eslintrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
module.exports = {
22
extends: ["airbnb", "eslint-config-prettier"],
3+
parserOptions: {
4+
parser: '@babel/eslint-parser',
5+
requireConfigFile: false, // <== ADD THIS
6+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
7+
sourceType: 'module' // Allows for the use of imports
8+
},
9+
310
plugins: ["prettier", "jest"],
411
env: {
512
browser: true,
@@ -12,7 +19,6 @@ module.exports = {
1219
"prettier/allowParens": "off",
1320
sourceType: 0,
1421
"no-restricted-syntax": ["off"],
15-
// why? just why is this even a thing? to make Js code look cool?
1622
"react/destructuring-assignment": ["off"],
1723
"react/jsx-filename-extension": ["off"],
1824
radix: "off",

package-lock.json

Lines changed: 101 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"build": "npm run build --ws && npm exec --ws -c ../../../scripts/deploy.sh && ./scripts/deployStatic.sh",
1212
"femFetch": "./scripts/femfetch.sh",
1313
"lint": "eslint .",
14+
"lint:ws": "npm exec --ws -c 'eslint --ext=.js,.jsx .'",
1415
"lint:fix": "eslint . --fix",
1516
"test:ws": "npm run test --if-present --ws",
1617
"format": "prettier --write ."
@@ -26,6 +27,7 @@
2627
},
2728
"homepage": "https://github.com/aadv1k/frontend-projects#readme",
2829
"devDependencies": {
30+
"@babel/eslint-parser": "^7.18.9",
2931
"@parcel/transformer-sass": "^2.6.2",
3032
"eslint": "^8.21.0",
3133
"eslint-config-airbnb": "^19.0.4",

packages/frontendmentor/fem-inbrowser-markdown-editor/src/App.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import DocumentContext from "./contexts/DocumentContext";
1010

1111
import "./App.css";
1212

13-
// Works ¯\_(ツ)_/¯heigh
13+
// Works ¯\_(ツ)_/¯
1414
// After refactoring the Navbar component to use DocumentContext I have come to
1515
// realize that there isn't much point using contexts in this case, the main
1616
// "issue" was the AppDrawer component, which required passing down props to a
@@ -68,7 +68,10 @@ export default class extends Component {
6868
}
6969

7070
setDrawerState() {
71-
this.setState({ drawer: !this.state.drawer });
71+
const { drawer } = this.state;
72+
this.setState({
73+
drawer: !drawer,
74+
});
7275
}
7376

7477
saveDocumentToLocalStorage(content, id, name, lastOpened = true) {

packages/frontendmentor/fem-inbrowser-markdown-editor/src/components/Navbar.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import style from "./Navbar.module.css";
1717
import Modal from "./Modal.jsx";
1818
import DocumentContext from "../contexts/DocumentContext";
1919

20-
export default class extends Component {
20+
export default class Navbar extends Component {
21+
static contextType = DocumentContext; // eslint-disable-line
2122
constructor(props) {
2223
super(props);
2324
this.inputRef = createRef();
@@ -27,8 +28,6 @@ export default class extends Component {
2728
};
2829
}
2930

30-
static contextType = DocumentContext;
31-
3231
setModalState() {
3332
this.setState({ modal: !this.state.modal });
3433
}

0 commit comments

Comments
 (0)