From 2ec84c68c7aed7dfc7c0283097df441f3b3d0979 Mon Sep 17 00:00:00 2001 From: matthieu-crouzet Date: Thu, 7 Nov 2024 11:46:56 +0100 Subject: [PATCH] feat(eslint): migrate sdk gh action release package --- tools/github-actions/release/.eslintrc.js | 17 --------- .../github-actions/release/eslint.config.mjs | 7 ++++ .../release/eslint.local.config.mjs | 36 +++++++++++++++++++ tools/github-actions/release/package.json | 25 +++++++------ tools/github-actions/release/project.json | 8 +---- .../release/src/get-previous-version.cts | 17 ++++++--- yarn.lock | 25 +++++++------ 7 files changed, 86 insertions(+), 49 deletions(-) delete mode 100644 tools/github-actions/release/.eslintrc.js create mode 100644 tools/github-actions/release/eslint.config.mjs create mode 100644 tools/github-actions/release/eslint.local.config.mjs diff --git a/tools/github-actions/release/.eslintrc.js b/tools/github-actions/release/.eslintrc.js deleted file mode 100644 index 6259cb035f..0000000000 --- a/tools/github-actions/release/.eslintrc.js +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -/* eslint-disable quote-props */ - -module.exports = { - 'root': true, - 'parserOptions': { - 'tsconfigRootDir': __dirname, - 'project': [ - 'tsconfig.json', - 'tsconfig.eslint.json' - ], - 'sourceType': 'module' - }, - 'extends': [ - '../../../.eslintrc.js' - ] -}; diff --git a/tools/github-actions/release/eslint.config.mjs b/tools/github-actions/release/eslint.config.mjs new file mode 100644 index 0000000000..87abd087fa --- /dev/null +++ b/tools/github-actions/release/eslint.config.mjs @@ -0,0 +1,7 @@ +import shared from '../../../eslint.shared.config.mjs'; +import local from './eslint.local.config.mjs'; + +export default [ + ...shared, + ...local +]; diff --git a/tools/github-actions/release/eslint.local.config.mjs b/tools/github-actions/release/eslint.local.config.mjs new file mode 100644 index 0000000000..bece969e07 --- /dev/null +++ b/tools/github-actions/release/eslint.local.config.mjs @@ -0,0 +1,36 @@ +import { + dirname +} from 'node:path'; +import { + fileURLToPath +} from 'node:url'; +import globals from 'globals'; + +const __filename = fileURLToPath(import.meta.url); +// __dirname is not defined in ES module scope +const __dirname = dirname(__filename); + +export default [ + { + name: '@o3r/new-version-gh-action/projects', + languageOptions: { + sourceType: 'module', + parserOptions: { + tsconfigRootDir: __dirname, + project: [ + 'tsconfig.build.json', + 'tsconfig.eslint.json' + ] + }, + globals: { + ...globals.node + } + } + }, + { + name: '@o3r/audit-gh-action/ignores', + ignores: [ + '**/packaged-action/**' + ] + } +]; diff --git a/tools/github-actions/release/package.json b/tools/github-actions/release/package.json index 441a434f1b..372af251aa 100644 --- a/tools/github-actions/release/package.json +++ b/tools/github-actions/release/package.json @@ -20,25 +20,30 @@ "tslib": "^2.6.2" }, "devDependencies": { - "@angular-eslint/eslint-plugin": "~18.3.0", + "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0", "@nx/eslint-plugin": "~19.5.0", - "@o3r/eslint-config-otter": "workspace:~", + "@o3r/eslint-config": "workspace:~", "@o3r/eslint-plugin": "workspace:~", - "@stylistic/eslint-plugin-ts": "~2.4.0", + "@stylistic/eslint-plugin": "~2.7.0", "@types/minimist": "^1.2.2", "@types/node": "^20.0.0", "@types/semver": "^7.3.13", - "@typescript-eslint/eslint-plugin": "^7.14.1", - "@typescript-eslint/parser": "^7.14.1", - "@typescript-eslint/utils": "^7.14.1", + "@typescript-eslint/parser": "~8.12.2", "@vercel/ncc": "~0.38.0", - "eslint": "^8.57.0", + "angular-eslint": "~18.3.0", + "eslint": "^9.0.0", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-import-newlines": "^1.4.0", "eslint-plugin-jest": "~28.8.0", - "eslint-plugin-jsdoc": "~48.11.0", + "eslint-plugin-jsdoc": "~50.2.0", "eslint-plugin-prefer-arrow": "~1.2.3", - "eslint-plugin-unicorn": "^54.0.0", + "eslint-plugin-sort-export-all": "^1.4.1", + "eslint-plugin-unicorn": "^55.0.0", + "eslint-plugin-unused-imports": "^4.1.4", + "globals": "^15.9.0", "jsonc-eslint-parser": "~2.4.0", - "typescript": "~5.5.4" + "typescript": "~5.5.4", + "typescript-eslint": "~8.12.2" }, "engines": { "node": "^18.19.1 || ^20.11.1 || >=22.0.0" diff --git a/tools/github-actions/release/project.json b/tools/github-actions/release/project.json index 744bd4b73a..bda17786c1 100644 --- a/tools/github-actions/release/project.json +++ b/tools/github-actions/release/project.json @@ -24,13 +24,7 @@ } }, "lint": { - "options": { - "eslintConfig": "tools/github-actions/release/.eslintrc.js", - "lintFilePatterns": [ - "tools/github-actions/release/src/**/*.ts", - "tools/github-actions/release/package.json" - ] - } + "executor": "nx:run-commands" } }, "tags": [] diff --git a/tools/github-actions/release/src/get-previous-version.cts b/tools/github-actions/release/src/get-previous-version.cts index 1e3ecca547..9d57008b89 100755 --- a/tools/github-actions/release/src/get-previous-version.cts +++ b/tools/github-actions/release/src/get-previous-version.cts @@ -1,6 +1,10 @@ #!/usr/bin/env node -import { valid, gt, lt } from 'semver'; import * as minimist from 'minimist'; +import { + gt, + lt, + valid +} from 'semver'; const argv = minimist(process.argv.slice(2)); const version = valid(argv._.at(0)); @@ -8,18 +12,21 @@ const version = valid(argv._.at(0)); let data = ''; async function main() { - for await (const chunk of process.stdin) data += chunk; + for await (const chunk of process.stdin) { + data += chunk; + } if (!version) { + // eslint-disable-next-line no-console -- only logger available console.error('Invalid version provided'); process.exit(1); } const previousVersion = (JSON.parse(data) as string[]) .filter((tag) => !!tag) - .map((tag) => ({tag, version: valid(tag)})) - .filter((item): item is { tag: string, version: string } => !!item.version) - .reduce<{tag: string, version: string} | undefined>((acc, item) => { + .map((tag) => ({ tag, version: valid(tag) })) + .filter((item): item is { tag: string; version: string } => !!item.version) + .reduce<{ tag: string; version: string } | undefined>((acc, item) => { if (lt(item.version, version) && (!acc || gt(item.version, acc.version))) { acc = item; } diff --git a/yarn.lock b/yarn.lock index 462688587f..0316ff69e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8596,7 +8596,7 @@ __metadata: languageName: unknown linkType: soft -"@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter, @o3r/eslint-config-otter@workspace:~": +"@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter": version: 0.0.0-use.local resolution: "@o3r/eslint-config-otter@workspace:packages/@o3r/eslint-config-otter" dependencies: @@ -31279,28 +31279,33 @@ __metadata: version: 0.0.0-use.local resolution: "release-gh-action@workspace:tools/github-actions/release" dependencies: - "@angular-eslint/eslint-plugin": "npm:~18.3.0" + "@eslint-community/eslint-plugin-eslint-comments": "npm:^4.4.0" "@nx/eslint-plugin": "npm:~19.5.0" - "@o3r/eslint-config-otter": "workspace:~" + "@o3r/eslint-config": "workspace:~" "@o3r/eslint-plugin": "workspace:~" - "@stylistic/eslint-plugin-ts": "npm:~2.4.0" + "@stylistic/eslint-plugin": "npm:~2.7.0" "@types/minimist": "npm:^1.2.2" "@types/node": "npm:^20.0.0" "@types/semver": "npm:^7.3.13" - "@typescript-eslint/eslint-plugin": "npm:^7.14.1" - "@typescript-eslint/parser": "npm:^7.14.1" - "@typescript-eslint/utils": "npm:^7.14.1" + "@typescript-eslint/parser": "npm:~8.12.2" "@vercel/ncc": "npm:~0.38.0" - eslint: "npm:^8.57.0" + angular-eslint: "npm:~18.3.0" + eslint: "npm:^9.0.0" + eslint-plugin-import: "npm:^2.31.0" + eslint-plugin-import-newlines: "npm:^1.4.0" eslint-plugin-jest: "npm:~28.8.0" - eslint-plugin-jsdoc: "npm:~48.11.0" + eslint-plugin-jsdoc: "npm:~50.2.0" eslint-plugin-prefer-arrow: "npm:~1.2.3" - eslint-plugin-unicorn: "npm:^54.0.0" + eslint-plugin-sort-export-all: "npm:^1.4.1" + eslint-plugin-unicorn: "npm:^55.0.0" + eslint-plugin-unused-imports: "npm:^4.1.4" + globals: "npm:^15.9.0" jsonc-eslint-parser: "npm:~2.4.0" minimist: "npm:^1.2.6" semver: "npm:^7.5.2" tslib: "npm:^2.6.2" typescript: "npm:~5.5.4" + typescript-eslint: "npm:~8.12.2" languageName: unknown linkType: soft