Skip to content

Commit

Permalink
Deps: add prettier config & adapt eslint config (#497)
Browse files Browse the repository at this point in the history
what is the motivation:

https://www.youtube.com/watch?v=Cd-gBxzcsdA

if this or accepted we should add format to git hooks

add run yarn format on all project

---------

Co-authored-by: Baruch Odem <baruchiro@gmail.com>
  • Loading branch information
Yedidyar and baruchiro authored Sep 10, 2023
1 parent e7832fa commit 6896315
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 36 deletions.
60 changes: 33 additions & 27 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,42 @@ const readonlyGlobals = Object.keys(globals).reduce((acc, key) => {
return acc;
}, {});

const productionError = process.env.NODE_ENV === 'production' ? 'error' : 'warn';
const productionError =
process.env.NODE_ENV === 'production' ? 'error' : 'warn';

module.exports = {
root: true,

parserOptions: {
parser: '@typescript-eslint/parser',
sourceType: 'module',
ecmaVersion: 2018
ecmaVersion: 2018,
},

env: {
browser: true,
node: true
node: true,
},

extends: ['airbnb-base', 'plugin:vue/recommended', '@vue/typescript'],
extends: [
'airbnb-base',
'plugin:vue/recommended',
'@vue/typescript',
'prettier',
],

globals: {
__static: 'writable',
...readonlyGlobals,
},

plugins: [
'import',
'vue',
'html',
],
plugins: ['import', 'vue', 'html'],

settings: {
'import/core-modules': ['electron'],
'import/resolver': {
alias: {
map: [
['@', './src'],
],
map: [['@', './src']],
extensions: ['.js', '.ts', '.vue', '.tsx'],
},
},
Expand All @@ -62,32 +62,38 @@ module.exports = {
'no-await-in-loop': 'off',
'import/prefer-default-export': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', { args: 'after-used', argsIgnorePattern: '^_|h' }],
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used', argsIgnorePattern: '^_|h' },
],
'arrow-body-style': 'off',
'object-curly-newline': 'warn',
'semi': productionError,
'object-curly-newline': 'off',
semi: productionError,
'padded-blocks': 'off',
'no-return-assign': 'off',
'quote-props': ['error', 'consistent-as-needed'],
'no-restricted-imports': ['error', {
name: 'electron-log',
importNames: ['default'],
message: 'You should import from logging/logger instead'
}]
'no-restricted-imports': [
'error',
{
name: 'electron-log',
importNames: ['default'],
message: 'You should import from logging/logger instead',
},
],
},

overrides: [
{
files: [
'**/test/**/*.spec.{j,t}s',
'**/*.test.{j,t}s'
],
files: ['**/test/**/*.spec.{j,t}s', '**/*.test.{j,t}s'],
env: {
jest: true,
},
rules: {
'import/extensions': ['error', { js: 'never', vue: 'always', json: 'always' }]
}
}
'import/extensions': [
'error',
{ js: 'never', vue: 'always', json: 'always' },
],
},
},
],
};
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint && yarn typeCheck
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"prebuild": "cd ui-react && yarn && yarn build",
"postinstall": "electron-builder install-app-deps && cd ui-react && yarn && cd ..",
"postuninstall": "electron-builder install-app-deps",
"prepare": "node scripts/copyCategoryCalculationScript.js",
"prepare": "node scripts/copyCategoryCalculationScript.js && husky install",
"lint:backend": "eslint -f ./node_modules/eslint-friendly-formatter src test",
"lint:react": "cd ui-react && yarn lint",
"lint": "yarn lint:backend && yarn lint:react",
Expand All @@ -28,10 +28,8 @@
"e2e": "vue-cli-service test:unit --config='test/e2e/jest.e2e.config.js'",
"test": "yarn unit && yarn e2e"
},
"husky": {
"hooks": {
"pre-push": "yarn lint && yarn typeCheck"
}
"lint-staged": {
"**/*": "prettier --write --ignore-unknown"
},
"dependencies": {
"@electron/remote": "^2.0.8",
Expand All @@ -51,6 +49,7 @@
"googleapis": "^87.0.0",
"israeli-bank-scrapers-core": "3.10.3",
"keytar": "^7.4.0",
"lint-staged": "~13.2.3",
"lodash": "^4.17.15",
"moment": "^2.29.4",
"node-machine-id": "^1.1.12",
Expand Down Expand Up @@ -98,6 +97,7 @@
"electron": "^17.0.0",
"eslint": "^7.1.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-loader": "^4.0.2",
Expand All @@ -108,7 +108,7 @@
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^5.0.0",
"eslint-plugin-vue": "^7.8.0",
"husky": "^4.2.5",
"husky": "^8.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.4.2",
"jest-circus": "^26.4.2",
Expand All @@ -117,6 +117,7 @@
"jest-environment-node": "^26.6.2",
"ncp": "^2.0.0",
"node-loader": "^1.0.2",
"prettier": "^3.0.3",
"replace-in-file": "5.0.2",
"sass": "~1.32",
"sass-loader": "^10.0.0",
Expand Down
Loading

0 comments on commit 6896315

Please sign in to comment.