From 594ed0cec3f2162f65b8ead2bd651106428dc7b1 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Tue, 14 Jun 2022 09:36:28 +0200 Subject: [PATCH 1/2] feat(eslint): remove generateImportOrderRule --- .eslintrc.js | 8 +++ backend/core/.eslintrc.js | 3 - backend/forum/.eslintrc.js | 3 - backend/users/.eslintrc.js | 3 - .../generateImportOrderRule.js | 61 ------------------- contracts/core-contracts/.eslintrc.js | 3 - contracts/forum-contracts/.eslintrc.js | 3 - contracts/users-contracts/.eslintrc.js | 3 - frontend/app/.eslintrc.js | 3 - frontend/cloudfront/.eslintrc.js | 3 - frontend/shared/.eslintrc.js | 3 - package.json | 3 +- packages/configuration/.eslintrc.js | 3 - .../serverless-configuration/.eslintrc.js | 3 - packages/serverless-helpers/.eslintrc.js | 3 - 15 files changed, 9 insertions(+), 99 deletions(-) delete mode 100644 commonConfiguration/generateImportOrderRule.js diff --git a/.eslintrc.js b/.eslintrc.js index 999b22ee..aad018e5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -33,11 +33,19 @@ module.exports = { 'import/order': [ 'error', { + pathGroups: [{ pattern: '@swarmion-starter/**', group: 'unknown' }], groups: [ ['external', 'builtin'], + 'unknown', 'internal', ['parent', 'sibling', 'index'], ], + alphabetize: { + order: 'asc', + caseInsensitive: false, + }, + 'newlines-between': 'always', + pathGroupsExcludedImportTypes: ['builtin'], }, ], 'sort-imports': [ diff --git a/backend/core/.eslintrc.js b/backend/core/.eslintrc.js index 028298d8..d96830bd 100644 --- a/backend/core/.eslintrc.js +++ b/backend/core/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/backend/forum/.eslintrc.js b/backend/forum/.eslintrc.js index 028298d8..d96830bd 100644 --- a/backend/forum/.eslintrc.js +++ b/backend/forum/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/backend/users/.eslintrc.js b/backend/users/.eslintrc.js index 028298d8..d96830bd 100644 --- a/backend/users/.eslintrc.js +++ b/backend/users/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/commonConfiguration/generateImportOrderRule.js b/commonConfiguration/generateImportOrderRule.js deleted file mode 100644 index cb2b9d50..00000000 --- a/commonConfiguration/generateImportOrderRule.js +++ /dev/null @@ -1,61 +0,0 @@ -const { readdirSync } = require('fs'); -const path = require('path'); - -const filterDirent = dirent => - dirent.isDirectory() || - (dirent.name.includes('.ts') && !dirent.name.includes('.test.ts')); - -const formatPathGroupsFromDirent = dirent => ({ - pattern: dirent.isDirectory() - ? `${dirent.name}{,/**}` - : dirent.name.replace('.ts', ''), - group: 'internal', -}); - -const generateImportOrderRule = (dirname, tsConfigPath = 'tsconfig.json') => { - const tsConfig = require(path.resolve(dirname, tsConfigPath)); - - const tsConfigPaths = Object.keys(tsConfig.compilerOptions.paths || {}).map( - compilerOptionPath => ({ - pattern: `${compilerOptionPath}*`, - group: 'internal', - }), - ); - - const baseUrlPaths = readdirSync( - path.resolve(dirname, tsConfig.compilerOptions.baseUrl || ''), - { - withFileTypes: true, - }, - ) - .filter(filterDirent) - .map(formatPathGroupsFromDirent); - - const pathGroups = [...tsConfigPaths, ...baseUrlPaths]; - - return { - 'import/order': [ - 'error', - { - pathGroups: [ - { pattern: '@swarmion-starter/**', group: 'unknown' }, - ...pathGroups, - ], - groups: [ - ['external', 'builtin'], - 'unknown', - 'internal', - ['parent', 'sibling', 'index'], - ], - alphabetize: { - order: 'asc', - caseInsensitive: false, - }, - 'newlines-between': 'always', - pathGroupsExcludedImportTypes: ['builtin'], - }, - ], - }; -}; - -module.exports = generateImportOrderRule; diff --git a/contracts/core-contracts/.eslintrc.js b/contracts/core-contracts/.eslintrc.js index 028298d8..d96830bd 100644 --- a/contracts/core-contracts/.eslintrc.js +++ b/contracts/core-contracts/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/contracts/forum-contracts/.eslintrc.js b/contracts/forum-contracts/.eslintrc.js index 028298d8..d96830bd 100644 --- a/contracts/forum-contracts/.eslintrc.js +++ b/contracts/forum-contracts/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/contracts/users-contracts/.eslintrc.js b/contracts/users-contracts/.eslintrc.js index 028298d8..d96830bd 100644 --- a/contracts/users-contracts/.eslintrc.js +++ b/contracts/users-contracts/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/frontend/app/.eslintrc.js b/frontend/app/.eslintrc.js index 028298d8..d96830bd 100644 --- a/frontend/app/.eslintrc.js +++ b/frontend/app/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/frontend/cloudfront/.eslintrc.js b/frontend/cloudfront/.eslintrc.js index 028298d8..d96830bd 100644 --- a/frontend/cloudfront/.eslintrc.js +++ b/frontend/cloudfront/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/frontend/shared/.eslintrc.js b/frontend/shared/.eslintrc.js index 028298d8..d96830bd 100644 --- a/frontend/shared/.eslintrc.js +++ b/frontend/shared/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/package.json b/package.json index d4f332b5..5b796acd 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,7 @@ "generate-service": "nx generate @swarmion/nx-plugin:service", "graph": "nx dep-graph", "info": "nx run-many --target=sls-info --all --parallel=4", - "lint-fix": "yarn linter-base-config --fix", - "lint-fix-all": "nx run-many --target=lint-fix-all --all --parallel=4", + "lint-fix": "nx run-many --target=lint-fix --all --parallel=4", "linter-base-config": "eslint", "package": "nx run-many --target=package --all --parallel=4", "postinstall": "husky install && syncpack format", diff --git a/packages/configuration/.eslintrc.js b/packages/configuration/.eslintrc.js index 028298d8..d96830bd 100644 --- a/packages/configuration/.eslintrc.js +++ b/packages/configuration/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/packages/serverless-configuration/.eslintrc.js b/packages/serverless-configuration/.eslintrc.js index 028298d8..d96830bd 100644 --- a/packages/serverless-configuration/.eslintrc.js +++ b/packages/serverless-configuration/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, diff --git a/packages/serverless-helpers/.eslintrc.js b/packages/serverless-helpers/.eslintrc.js index 028298d8..d96830bd 100644 --- a/packages/serverless-helpers/.eslintrc.js +++ b/packages/serverless-helpers/.eslintrc.js @@ -1,7 +1,4 @@ -const generateImportOrderRule = require('../../commonConfiguration/generateImportOrderRule'); - module.exports = { - rules: generateImportOrderRule(__dirname), parserOptions: { project: ['./tsconfig.json'], tsconfigRootDir: __dirname, From 89eae0e2da2ecbdc66a9a93030c693d17db941fd Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Tue, 14 Jun 2022 10:30:31 +0200 Subject: [PATCH 2/2] chore: update swarmion packages --- backend/forum/package.json | 2 +- backend/users/package.json | 2 +- contracts/core-contracts/package.json | 2 +- contracts/forum-contracts/package.json | 2 +- contracts/users-contracts/package.json | 2 +- frontend/app/package.json | 2 +- package.json | 6 +++--- yarn.lock | 30 +++++++++++++------------- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/backend/forum/package.json b/backend/forum/package.json index 63e3ca5a..6d30dd19 100644 --- a/backend/forum/package.json +++ b/backend/forum/package.json @@ -26,7 +26,7 @@ "@swarmion-starter/forum-contracts": "1.0.0", "@swarmion-starter/serverless-configuration": "1.0.0", "@swarmion-starter/serverless-helpers": "1.0.0", - "@swarmion/serverless-contracts": "0.7.1", + "@swarmion/serverless-contracts": "0.7.2", "aws-sdk": "^2.1152.0", "http-errors": "^2.0.0" }, diff --git a/backend/users/package.json b/backend/users/package.json index e563e0a9..cdfb759e 100644 --- a/backend/users/package.json +++ b/backend/users/package.json @@ -26,7 +26,7 @@ "@swarmion-starter/serverless-configuration": "1.0.0", "@swarmion-starter/serverless-helpers": "1.0.0", "@swarmion-starter/users-contracts": "1.0.0", - "@swarmion/serverless-contracts": "0.7.1", + "@swarmion/serverless-contracts": "0.7.2", "aws-sdk": "^2.1152.0", "http-errors": "^2.0.0" }, diff --git a/contracts/core-contracts/package.json b/contracts/core-contracts/package.json index 5eb6d274..6f92481e 100644 --- a/contracts/core-contracts/package.json +++ b/contracts/core-contracts/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@babel/runtime": "^7.18.3", - "@swarmion/serverless-contracts": "0.7.1" + "@swarmion/serverless-contracts": "0.7.2" }, "devDependencies": { "@babel/cli": "^7.17.10", diff --git a/contracts/forum-contracts/package.json b/contracts/forum-contracts/package.json index 13cc692f..792ecd70 100644 --- a/contracts/forum-contracts/package.json +++ b/contracts/forum-contracts/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@babel/runtime": "^7.18.3", - "@swarmion/serverless-contracts": "0.7.1" + "@swarmion/serverless-contracts": "0.7.2" }, "devDependencies": { "@babel/cli": "^7.17.10", diff --git a/contracts/users-contracts/package.json b/contracts/users-contracts/package.json index 0f389b71..e0ad3f8e 100644 --- a/contracts/users-contracts/package.json +++ b/contracts/users-contracts/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@babel/runtime": "^7.18.3", - "@swarmion/serverless-contracts": "0.7.1" + "@swarmion/serverless-contracts": "0.7.2" }, "devDependencies": { "@babel/cli": "^7.17.10", diff --git a/frontend/app/package.json b/frontend/app/package.json index c8a345da..4a173f1a 100644 --- a/frontend/app/package.json +++ b/frontend/app/package.json @@ -32,7 +32,7 @@ "@swarmion-starter/configuration": "1.0.0", "@swarmion-starter/frontend-shared": "1.0.0", "@swarmion-starter/users-contracts": "1.0.0", - "@swarmion/serverless-contracts": "0.7.1", + "@swarmion/serverless-contracts": "0.7.2", "axios": "0.27.2", "react": "^17.0.2", "react-dom": "^17.0.2", diff --git a/package.json b/package.json index 5b796acd..f7996225 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "workspaces": [ "backend/*", "contracts/*", - "packages/*", - "frontend/*" + "frontend/*", + "packages/*" ], "scripts": { "build-all": "nx run-many --target=build --all --parallel=4", @@ -37,7 +37,7 @@ "@nrwl/linter": "^14.2.4", "@nrwl/tao": "^14.2.4", "@nrwl/workspace": "^14.2.4", - "@swarmion/nx-plugin": "0.7.1", + "@swarmion/nx-plugin": "0.7.2", "@types/jest": "^27.5.2", "@typescript-eslint/eslint-plugin": "^5.27.1", "@typescript-eslint/parser": "^5.27.1", diff --git a/yarn.lock b/yarn.lock index 240f5677..b41e9b4d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3198,7 +3198,7 @@ __metadata: "@swarmion-starter/forum-contracts": 1.0.0 "@swarmion-starter/serverless-configuration": 1.0.0 "@swarmion-starter/serverless-helpers": 1.0.0 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@types/http-errors": ^1.8.2 "@types/jest": ^27.5.2 "@types/node": ^17.0.41 @@ -3227,7 +3227,7 @@ __metadata: "@swarmion-starter/serverless-configuration": 1.0.0 "@swarmion-starter/serverless-helpers": 1.0.0 "@swarmion-starter/users-contracts": 1.0.0 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@types/http-errors": ^1.8.2 "@types/jest": ^27.5.2 "@types/node": ^17.0.41 @@ -3282,7 +3282,7 @@ __metadata: "@babel/preset-env": ^7.18.2 "@babel/preset-typescript": ^7.17.12 "@babel/runtime": ^7.18.3 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@types/node": ^17.0.41 "@zerollup/ts-transform-paths": ^1.7.18 babel-plugin-module-resolver: ^4.1.0 @@ -3307,7 +3307,7 @@ __metadata: "@babel/preset-env": ^7.18.2 "@babel/preset-typescript": ^7.17.12 "@babel/runtime": ^7.18.3 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@types/node": ^17.0.41 "@zerollup/ts-transform-paths": ^1.7.18 babel-plugin-module-resolver: ^4.1.0 @@ -3340,7 +3340,7 @@ __metadata: "@swarmion-starter/configuration": 1.0.0 "@swarmion-starter/frontend-shared": 1.0.0 "@swarmion-starter/users-contracts": 1.0.0 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@testing-library/dom": ^8.13.0 "@testing-library/jest-dom": ^5.16.4 "@testing-library/react": ^12.1.5 @@ -3463,7 +3463,7 @@ __metadata: "@nrwl/linter": ^14.2.4 "@nrwl/tao": ^14.2.4 "@nrwl/workspace": ^14.2.4 - "@swarmion/nx-plugin": 0.7.1 + "@swarmion/nx-plugin": 0.7.2 "@types/jest": ^27.5.2 "@typescript-eslint/eslint-plugin": ^5.27.1 "@typescript-eslint/parser": ^5.27.1 @@ -3556,7 +3556,7 @@ __metadata: "@babel/preset-env": ^7.18.2 "@babel/preset-typescript": ^7.17.12 "@babel/runtime": ^7.18.3 - "@swarmion/serverless-contracts": 0.7.1 + "@swarmion/serverless-contracts": 0.7.2 "@types/node": ^17.0.41 "@zerollup/ts-transform-paths": ^1.7.18 babel-plugin-module-resolver: ^4.1.0 @@ -3572,22 +3572,22 @@ __metadata: languageName: unknown linkType: soft -"@swarmion/nx-plugin@npm:0.7.1": - version: 0.7.1 - resolution: "@swarmion/nx-plugin@npm:0.7.1" - checksum: e9b6d32e6f20dc30d44bccbb7101335ebb711d420605e54257332dbfb3073644a5879ea6a79d8679e0ff54961407db92b38c3ddde2ac22eccb220b2a5c37586b +"@swarmion/nx-plugin@npm:0.7.2": + version: 0.7.2 + resolution: "@swarmion/nx-plugin@npm:0.7.2" + checksum: 21ce09b7daa50e9479da9b36bb3a54983378b62a3758e7e20528a0a246fc78743fe7b4a63716325454855c82ace9273f9e7062928a3f971d62f7ba6e0e734abf languageName: node linkType: hard -"@swarmion/serverless-contracts@npm:0.7.1": - version: 0.7.1 - resolution: "@swarmion/serverless-contracts@npm:0.7.1" +"@swarmion/serverless-contracts@npm:0.7.2": + version: 0.7.2 + resolution: "@swarmion/serverless-contracts@npm:0.7.2" dependencies: "@babel/runtime": ^7.18.3 lodash: ^4.17.21 peerDependencies: axios: ^0.27.2 - checksum: a778206c32e851910d013ba37b8ea0f2e50f95ca0ce83aff27760ebea6c5c8650f0cfde88caddc8838e8417ad497931cfc7419692c66981a46166b34357f3782 + checksum: c39da50dbb37bc9a715b6fbfbfd5fdf37892d029409ab24cce185bf950a96754c0fd66b11e63bfbb49f8508c1045427b8545c65a12142bb25f174aa2006eb430 languageName: node linkType: hard