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

Perf/improve eslint config & bump packages #614

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
node_modules/
node_modules
build/
build
dist/
dist
_templates/
coverage/
*.generated.ts
Expand Down
41 changes: 30 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
module.exports = {
parserOptions: {
root: true,
project: ['./packages/*/tsconfig.json', 'tsconfig.dev.json', './www/tsconfig.json'],
tsconfigRootDir: __dirname,
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
extends: [
'eslint:recommended',
'plugin:eslint-comments/recommended',
'plugin:node/recommended',
'plugin:promise/recommended',
'airbnb',
'airbnb/hooks',
'airbnb-typescript',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:prettier/recommended',
'plugin:regexp/recommended',
'plugin:security/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
'plugin:testing-library/react',
'plugin:cypress/recommended',
'plugin:jsdoc/recommended',
'prettier',
],
plugins: ['simple-import-sort'],
rules: {
semi: 'off',
'no-void': 0,
'consistent-return': 0,
'no-console': 0,
'operator-linebreak': [2, 'after', { overrides: { '?': 'before', ':': 'before' } }],
'no-use-before-define': 0,

'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false,
},
],
'@typescript-eslint/semi': 2,
'@typescript-eslint/indent': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
Expand Down Expand Up @@ -68,19 +71,35 @@ module.exports = {
'simple-import-sort/imports': 2,
'simple-import-sort/exports': 2,

// TypeScript provides the same checks as part of standard type checking.
// https://typescript-eslint.io/docs/linting/troubleshooting#eslint-plugin-import
'import/named': 0,
'import/namespace': 0,
'import/default': 0,
'import/no-named-as-default-member': 0,

'import/first': 2,
'import/newline-after-import': 2,
'import/prefer-default-export': 0,
'import/no-extraneous-dependencies': 0,
'import/no-duplicates': 2,
'import/extensions': [2, 'never', { json: 'always' }],

'react/react-in-jsx-scope': 0,
'react/jsx-uses-react': 0,
'react/prop-types': 0,
'react/require-default-props': 0,
'react/jsx-boolean-value': [2, 'never'],
'react/jsx-props-no-spreading': 0,
'react/display-name': 0,
'react/react-in-jsx-scope': 0,
'react/no-unstable-nested-components': 0,
'react/function-component-definition': [
2,
{
namedComponents: 'arrow-function',
unnamedComponents: 'arrow-function',
},
],

'jsx-a11y/click-events-have-key-events': 0, // Disabled (https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/click-events-have-key-events.md)

Expand All @@ -94,7 +113,7 @@ module.exports = {
'promise/always-return': 0,

'jest/consistent-test-it': 2,
'jest/lowercase-name': 2,
'jest/prefer-lowercase-title': 2,
'jest/require-top-level-describe': 2,

'jsdoc/require-param-type': 0,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- name: 'Git checkout'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/continous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- name: 'Git checkout'
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
container: cypress/browsers:node12.18.3-chrome87-ff82
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
env:
NODE_ENV: 'test'
DB_PORT: 5432
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- name: 'Git checkout'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]

steps:
- name: 'Git checkout'
Expand Down
14 changes: 7 additions & 7 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
message: 'If you use this software, please cite it as below.'
authors:
- family-names: "Jakub"
given-names: "Jóźwiak"
- family-names: "Mateusz"
given-names: "Nestorowicz"
title: "Smart Gate System"
- family-names: 'Jakub'
given-names: 'Jóźwiak'
- family-names: 'Mateusz'
given-names: 'Nestorowicz'
title: 'Smart Gate System'
date-released: 2021-01-08
url: "https://github.com/Jozwiaczek/smart-gate"
url: 'https://github.com/Jozwiaczek/smart-gate'
51 changes: 23 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@
"preinstall": "node -e \"if (process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('Use yarn for installing')\"",
"lint": "lerna run lint",
"lint:fix": "lerna run lint:fix",
"prepare": "husky install",
"prettier": "prettier --check .",
"prettier:fix": "prettier --write .",
"prepare": "husky install",
"removeNodeModules": "find . -name \"node_modules\" -type d -prune -exec rm -rf '{}' +",
"removeEslintCaches": "find . -name \".eslintcache\" -prune -exec rm '{}' +",
"removeNodeModules": "find . -name \"node_modules\" -type d -prune -exec rm -rf '{}' +",
"sortPackageJson": "sort-package-json && lerna exec sort-package-json",
"start": "cd packages/api && yarn start:prod",
"start:ci": "concurrently \"cd packages/client && NODE_ENV=test yarn start\" \"cd packages/api && NODE_ENV=test yarn start\"",
"test": "lerna run test",
"type-check": "lerna run type-check"
},
"resolutions": {
"babel-loader": "8.1.0"
},
"dependencies": {
"@types/nodemailer": "^6.4.4",
"base64url": "^3.0.1",
Expand All @@ -55,40 +52,38 @@
"@commitlint/config-lerna-scopes": "^13.1.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.1",
"@types/node": "^16.9.1",
"@types/node": "^18.0.0",
"@types/pg": "^8.6.1",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"concurrently": "^6.2.1",
"enquirer": "^2.3.6",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "^14.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-loader": "^4.0.2",
"eslint": "^8.17.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-jsdoc": "^37.0.3",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.5.3",
"eslint-plugin-jsdoc": "^39.3.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.25.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-regexp": "^1.1.0",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-regexp": "^1.7.0",
"eslint-plugin-security": "^1.5.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-testing-library": "^4.12.2",
"husky": "^7.0.2",
"eslint-plugin-testing-library": "^5.5.1",
"husky": "^8.0.1",
"hygen": "^6.1.0",
"lerna": "^4.0.0",
"lint-staged": "^11.1.2",
"prettier": "^2.4.0",
"lint-staged": "^13.0.1",
"prettier": "^2.7.0",
"rimraf": "^3.0.2",
"serve": "^12.0.1",
"sort-package-json": "^1.51.0"
"sort-package-json": "^1.57.0"
},
"engines": {
"node": ">=14",
Expand Down
3 changes: 1 addition & 2 deletions packages/api/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules/
build/
build
10 changes: 5 additions & 5 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"@types/web-push": "^3.3.2",
"bcrypt": "^5.0.1",
"cache-manager": "^3.4.4",
"class-transformer": "^0.4.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.1",
"cookie-parser": "^1.4.5",
"helmet": "^4.6.0",
Expand All @@ -55,16 +55,16 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.3.0",
"ts-loader": "^9.2.5",
"ts-loader": "^9.3.0",
"tsconfig-paths": "^3.11.0",
"typeorm": "^0.2.37",
"uuid": "^8.3.2",
"web-push": "^3.4.5"
},
"devDependencies": {
"@nestjs/testing": "^8.0.6",
"@types/jest": "^27.0.1",
"jest": "^27.2.0",
"ts-jest": "^27.0.5"
"@types/jest": "^28.1.1",
"jest": "^28.1.1",
"ts-jest": "^28.0.5"
}
}
14 changes: 7 additions & 7 deletions packages/api/src/modules/history/history.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('history service', () => {
await testClearRepository(connection, HistoryEntity);
const emptyHistory = await historyService.findAll();

expect(emptyHistory.total).toStrictEqual(0);
expect(emptyHistory.total).toBe(0);
expect(emptyHistory.data).toStrictEqual([]);
});

Expand All @@ -53,7 +53,7 @@ describe('history service', () => {
await testCreateHistoryRecord(connection, HistoryEvent.Open);

const fullHistory = await historyService.findAll();
expect(fullHistory.total).toEqual(3);
expect(fullHistory.total).toBe(3);
});
});

Expand All @@ -68,7 +68,7 @@ describe('history service', () => {

const emptyHistory = await historyService.findAllByUserId(testUser.id);

expect(emptyHistory.total).toStrictEqual(0);
expect(emptyHistory.total).toBe(0);
});

it('returns user history', async () => {
Expand All @@ -82,7 +82,7 @@ describe('history service', () => {

const userHistory = await historyService.findAllByUserId(testUser.id);

expect(userHistory.total).toStrictEqual(2);
expect(userHistory.total).toBe(2);
});
});

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('history service', () => {
const repository = await testClearRepository(connection, HistoryEntity);
await testCreateHistoryRecord(connection, HistoryEvent.TurnedOn);

await expect(repository.count()).resolves.toStrictEqual(1);
await expect(repository.count()).resolves.toBe(1);
await expect(historyService.remove('INVALID_ID')).rejects.toBeInstanceOf(QueryFailedError);
});

Expand All @@ -133,7 +133,7 @@ describe('history service', () => {
firstHistoryRecord,
secondHistoryRecord,
]);
await expect(historyService.remove(firstHistoryRecord.id)).resolves.toStrictEqual(true);
await expect(historyService.remove(firstHistoryRecord.id)).resolves.toBe(true);
await expect(repository.find()).resolves.toStrictEqual([secondHistoryRecord]);
await expect(repository.findOne({ id: firstHistoryRecord.id })).resolves.toBeUndefined();
});
Expand All @@ -144,7 +144,7 @@ describe('history service', () => {
const repository = await testClearRepository(connection, HistoryEntity);
await testCreateHistoryRecord(connection, HistoryEvent.TurnedOn);

await expect(repository.count()).resolves.toStrictEqual(1);
await expect(repository.count()).resolves.toBe(1);
await expect(historyService.removeMany({ ids: ['INVALID_ID'] })).rejects.toBeInstanceOf(
BadRequestException,
);
Expand Down
Loading