Merge pull request #526 from filecoin-project/chore/devx

chore: add eslint config and husky lint-staged checks
This commit is contained in:
Chris Waring 2021-02-18 13:38:02 +00:00 committed by GitHub
commit 767287e891
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1818 additions and 5 deletions

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
node_modules
dist
vendor

50
.eslintrc.js Normal file
View File

@ -0,0 +1,50 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: "detect",
},
},
env: {
browser: true,
node: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended", // last item for prettier config to take priority
],
rules: {
"prettier/prettier": ["error", {}, { usePrettierrc: true }],
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"jsx-a11y/anchor-is-valid": [
"error",
{
components: ["Link"], // next.js rules
specialLink: ["hrefLeft", "hrefRight"],
aspects: ["invalidHref", "preferButton"],
},
],
"prefer-destructuring": [
"error",
{
array: true,
object: true,
},
{
enforceForRenamedProperties: false,
},
],
},
};

8
.githooks/post-merge Normal file
View File

@ -0,0 +1,8 @@
function changed {
git diff --name-only HEAD@{1} HEAD | grep "^$1" > /dev/null 2>&1
}
if changed 'package-lock.json'; then
echo "📦 package-lock.json changed. Installing the latest dependencies.";
npm install
fi

1735
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,9 +7,21 @@
"engines": {
"node": "14.7.0"
},
"lint-staged": {
"./**/*.{json,yaml,md}": "prettier --write",
"./**/*.{js,jsx}": "eslint --cache --fix"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"post-merge": "./.githooks/post-merge"
}
},
"scripts": {
"dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 node . --unhandled-rejections=strict --max-old-space-size=8192",
"start": "NODE_ENV=production node . --unhandled-rejections=strict --max-old-space-size=8192",
"lint": "eslint . --ext .js",
"lint:fix": "npm run lint -- --fix",
"build": "NODE_ENV=production next build",
"build-system": "rollup -c",
"scripts": "NODE_TLS_REJECT_UNAUTHORIZED=0 node --max-old-space-size=8192 ./scripts",
@ -70,6 +82,15 @@
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^5.0.9",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"rollup": "^2.39.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^4.2.0"

6
scripts/.eslintrc.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
env: {
browser: false,
amd: true,
},
};