Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Pre-commit Hooks & Improving Prettier/ESLint rules #439

Merged
merged 11 commits into from
Dec 2, 2024
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint-staged
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
package-lock.json
dist
lint-*
14 changes: 12 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"printWidth": 180,
"singleQuote": true
"printWidth": 120,
"quoteProps": "consistent",
"singleQuote": true,
"trailingComma": "es5",
"useTabs": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume you are going to have a lot of whitespace updates in your commits going forward with this. Do you want that?

Copy link
Member Author

@BboyAkers BboyAkers Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm 🤔 I'll look into:

  • Creating a separate PR running prettier & ESLint on the entire app
    and/or
  • Investigating if it's possible to run prettier and not affect the git history

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually the strategy is to add (mass) prettier/lint commits in .git-blame-ignore-revs: https://github.com/HarperDB/harperdb/blob/main/.git-blame-ignore-revs
I just didn't know if you really wanted to do that right now.

"endOfLine": "auto",
"tabWidth": 2,
"semi": true,
"bracketSameLine": false,
"bracketSpacing": true,
"jsxSingleQuote": false,
"arrowParens": "always"
}
72 changes: 40 additions & 32 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,52 @@ import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [...fixupConfigRules(
compat.extends("react-app", "airbnb", "plugin:jsx-a11y/recommended", "prettier"),
), {
export default [
...fixupConfigRules(compat.extends("react-app", "airbnb", "plugin:jsx-a11y/recommended", "prettier")),
{
// root: true,
plugins: {
"jsx-a11y": fixupPluginRules(jsxA11Y),
prettier
"jsx-a11y": fixupPluginRules(jsxA11Y),
prettier,
},

rules: {
camelcase: 0,
"no-nested-ternary": 0,
"no-param-reassign": 0,
"no-return-assign": 0,
"no-restricted-syntax": 0,
"react/jsx-filename-extension": 0,
"react/jsx-props-no-spreading": 0,
"react/destructuring-assignment": 0,
"react/prop-types": 0,
"react/no-danger": 0,
"no-unused-vars": 1,
"react/button-has-type": 1,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"no-underscore-dangle": ["warn", {
allow: ["_kmq", "_kmk"],
}],
"no-unsafe-optional-chaining": 0,
"jsx-a11y/label-has-associated-control": 0,
"react/jsx-no-bind": 0,
camelcase: 0,
"import/no-extraneous-dependencies": ["error", { devDependencies: true }],
"no-nested-ternary": 0,
"no-param-reassign": 0,
"no-return-assign": 0,
"no-restricted-syntax": 0,
"react/jsx-filename-extension": 0,
"react/jsx-props-no-spreading": 0,
"react/destructuring-assignment": 0,
"react/prop-types": 0,
"react/no-danger": 0,
"no-unused-vars": 1,
"react/button-has-type": 1,
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"no-underscore-dangle": [
"warn",
{
allow: ["_kmq", "_kmk"],
},
],
"no-unsafe-optional-chaining": 0,
"jsx-a11y/label-has-associated-control": 0,
"react/jsx-no-bind": 0,

"react/no-unstable-nested-components": ["warn", {
allowAsProps: true,
}],
"react/no-unstable-nested-components": [
"warn",
{
allowAsProps: true,
},
],
},
}];
},
];
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build:prod": "DISABLE_ESLINT_PLUGIN=true GENERATE_SOURCEMAP=false PUBLIC_URL=https://ds5zz9rfvzuta.cloudfront.net react-scripts build",
"build:local": "DISABLE_ESLINT_PLUGIN=true BUILD_PATH=./build-local GENERATE_SOURCEMAP=false REACT_APP_LOCALSTUDIO=true react-scripts build",
"lint-dev": "eslint --fix src && npx stylelint --fix \"src/**/*.scss\"",
"lint-prod": "eslint --fix src"
"lint-prod": "eslint --fix src",
"prepare": "husky"
},
"dependencies": {
"@monaco-editor/react": "^4.2.0",
Expand Down Expand Up @@ -50,7 +51,7 @@
"whatwg-fetch": "^3.6.2"
},
"engines": {
"node": ">=14.0.0"
"node": ">=20.18.0"
BboyAkers marked this conversation as resolved.
Show resolved Hide resolved
},
"browserslist": {
"production": [
Expand All @@ -64,6 +65,12 @@
"last 1 safari version"
]
},
"lint-staged": {
"**/*": [
"prettier --write --ignore-unknown",
"eslint --fix"
]
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/compat": "^1.1.1",
Expand All @@ -76,6 +83,9 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-react-hooks": "^4.6.2",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"pinst": "^3.0.0",
"postcss-custom-properties": "^14.0.1",
"prettier": "^3.1.0",
"sass": "^1.46.0",
Expand Down
Loading