From 04543dc310f5f3074ba26d92f1cf8b063962a2d7 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Mon, 9 Oct 2023 13:26:36 -0700 Subject: [PATCH] feat!: use perfectionist (#70) * feat!: use perfectionist BREAKING CHANGES: use perfectionist, remove various disabled rules * chore: linting --- .git2gus/config.json | 7 ++ .github/workflows/automerge.yml | 7 +- .github/workflows/create-github-release.yml | 28 ++++++++ .github/workflows/failureNotifications.yml | 2 +- .github/workflows/manualRelease.yml | 36 ---------- .github/workflows/onPushToMain.yml | 18 ----- .github/workflows/onRelease.yml | 22 ++++-- .github/workflows/test.yml | 7 +- .prettierrc.json | 1 + .releaserc | 5 -- git2gus/config.json | 4 -- index.js | 78 ++++++++++++-------- package.json | 6 +- yarn.lock | 80 +++++++++++++++++++++ 14 files changed, 195 insertions(+), 106 deletions(-) create mode 100644 .git2gus/config.json create mode 100644 .github/workflows/create-github-release.yml delete mode 100644 .github/workflows/manualRelease.yml delete mode 100644 .github/workflows/onPushToMain.yml create mode 100644 .prettierrc.json delete mode 100644 .releaserc delete mode 100644 git2gus/config.json diff --git a/.git2gus/config.json b/.git2gus/config.json new file mode 100644 index 0000000..7943881 --- /dev/null +++ b/.git2gus/config.json @@ -0,0 +1,7 @@ +{ + "productTag": "a1aB0000000ce2IIAQ", + "defaultBuild": "offcore.tooling.59", + "issueTypeLabels": { "enhancement": "USER STORY", "bug": "BUG P3" }, + "hideWorkItemUrl": true, + "statusWhenClosed": "CLOSED" +} diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 16d0657..52279e1 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -2,11 +2,12 @@ name: automerge on: workflow_dispatch: schedule: - - cron: '17 2,5,8,11 * * *' + - cron: "42 2,5,8,11 * * *" jobs: automerge: - uses: oclif/github-workflows/.github/workflows/automerge.yml@main - secrets: inherit + uses: salesforcecli/github-workflows/.github/workflows/automerge.yml@main + secrets: + SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} with: mergeMethod: squash diff --git a/.github/workflows/create-github-release.yml b/.github/workflows/create-github-release.yml new file mode 100644 index 0000000..136463a --- /dev/null +++ b/.github/workflows/create-github-release.yml @@ -0,0 +1,28 @@ +name: create-github-release + +on: + push: + branches: + - main + # point at specific branches, or a naming convention via wildcard + - prerelease/** + tags-ignore: + - '*' + workflow_dispatch: + inputs: + prerelease: + type: string + description: 'Name to use for the prerelease: beta, dev, etc. NOTE: If this is already set in the package.json, it does not need to be passed in here.' + +jobs: + release: + # this job will throw if prerelease is true but it doesn't have a prerelease-looking package.json version + uses: salesforcecli/github-workflows/.github/workflows/create-github-release.yml@main + secrets: + SVC_CLI_BOT_GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} + with: + prerelease: ${{ inputs.prerelease }} + # If this is a push event, we want to skip the release if there are no semantic commits + # However, if this is a manual release (workflow_dispatch), then we want to disable skip-on-empty + # This helps recover from forgetting to add semantic commits ('fix:', 'feat:', etc.) + skip-on-empty: ${{ github.event_name == 'push' }} diff --git a/.github/workflows/failureNotifications.yml b/.github/workflows/failureNotifications.yml index 6b4118f..d3e86d7 100644 --- a/.github/workflows/failureNotifications.yml +++ b/.github/workflows/failureNotifications.yml @@ -3,7 +3,7 @@ name: failureNotifications on: workflow_run: workflows: - - version, tag and github release + - create-github-release - publish types: - completed diff --git a/.github/workflows/manualRelease.yml b/.github/workflows/manualRelease.yml deleted file mode 100644 index 8ceb52c..0000000 --- a/.github/workflows/manualRelease.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: manual release - -on: - workflow_dispatch: - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - - name: Conventional Changelog Action - id: changelog - uses: TriPSs/conventional-changelog-action@d360fad3a42feca6462f72c97c165d60a02d4bf2 - # overriding some of the basic behaviors to just get the changelog - with: - git-user-name: svc-cli-bot - git-user-email: svc_cli_bot@salesforce.com - github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - output-file: false - # always do the release, even if there are no semantic commits - skip-on-empty: false - tag-prefix: '' - - uses: notiz-dev/github-action-json-property@2192e246737701f108a4571462b76c75e7376216 - id: packageVersion - with: - path: 'package.json' - prop_path: 'version' - - name: Create Github Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }} - with: - tag_name: ${{ steps.packageVersion.outputs.prop }} - release_name: ${{ steps.packageVersion.outputs.prop }} diff --git a/.github/workflows/onPushToMain.yml b/.github/workflows/onPushToMain.yml deleted file mode 100644 index 61eda8a..0000000 --- a/.github/workflows/onPushToMain.yml +++ /dev/null @@ -1,18 +0,0 @@ -# test -name: version, tag and github release - -on: - push: - branches: [main] - -jobs: - release: - uses: oclif/github-workflows/.github/workflows/githubRelease.yml@main - secrets: inherit - - # most repos won't use this - # depends on previous job to avoid git collisions, not for any functionality reason - # docs: - # uses: salesforcecli/github-workflows/.github/workflows/publishTypedoc.yml@main - # secrets: inherit - # needs: release diff --git a/.github/workflows/onRelease.yml b/.github/workflows/onRelease.yml index 8876db4..02bebdf 100644 --- a/.github/workflows/onRelease.yml +++ b/.github/workflows/onRelease.yml @@ -2,7 +2,7 @@ name: publish on: release: - types: [released] + types: [published] # support manual release in case something goes wrong and needs to be repeated or tested workflow_dispatch: inputs: @@ -11,9 +11,23 @@ on: type: string required: true jobs: + # parses the package.json version and detects prerelease tag (ex: beta from 4.4.4-beta.0) + getDistTag: + outputs: + tag: ${{ steps.distTag.outputs.tag }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name || inputs.tag }} + - uses: salesforcecli/github-workflows/.github/actions/getPreReleaseTag@main + id: distTag + npm: - uses: oclif/github-workflows/.github/workflows/npmPublish.yml@main + uses: salesforcecli/github-workflows/.github/workflows/npmPublish.yml@main + needs: [getDistTag] with: - tag: latest + tag: ${{ needs.getDistTag.outputs.tag || 'latest' }} githubTag: ${{ github.event.release.tag_name || inputs.tag }} - secrets: inherit + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4286a55..9c5ba9f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,5 +5,8 @@ on: workflow_dispatch: jobs: - unit-tests: - uses: oclif/github-workflows/.github/workflows/unitTest.yml@main + yarn-lockfile-check: + uses: salesforcecli/github-workflows/.github/workflows/lockFileCheck.yml@main + linux-unit-tests: + needs: yarn-lockfile-check + uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..6314335 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1 @@ +"@oclif/prettier-config" diff --git a/.releaserc b/.releaserc deleted file mode 100644 index 345a296..0000000 --- a/.releaserc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "branches": [ - "main" - ] -} \ No newline at end of file diff --git a/git2gus/config.json b/git2gus/config.json deleted file mode 100644 index c8eda1c..0000000 --- a/git2gus/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "productTag": "a1aB00000004Bx8IAE", - "defaultBuild": "offcore.tooling.55" -} \ No newline at end of file diff --git a/index.js b/index.js index 5ef4884..08c1843 100644 --- a/index.js +++ b/index.js @@ -1,40 +1,56 @@ module.exports = { extends: [ - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:node/recommended", - "plugin:import/recommended", - "plugin:import/typescript", + 'plugin:@typescript-eslint/eslint-recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:node/recommended', + 'plugin:import/recommended', + 'plugin:import/typescript', + 'plugin:perfectionist/recommended-natural', ], - settings: { - "import/parsers": { - "@typescript-eslint/parser": [".ts", ".tsx"] - }, - "import/resolver": { - "typescript": { - "alwaysTryTypes": true - } - } - }, parser: '@typescript-eslint/parser', plugins: ['@typescript-eslint', 'import'], rules: { - "@typescript-eslint/camelcase": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-namespace": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unused-vars": [ - "error", + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + }, + ], + '@typescript-eslint/no-var-requires': 'off', + 'import/no-unresolved': 'error', + 'no-unused-expressions': 'off', + 'node/no-missing-import': 'off', + 'node/no-unsupported-features/es-syntax': 'off', + 'perfectionist/sort-classes': [ + 'error', { - "argsIgnorePattern": "^_" - } + groups: [ + 'index-signature', + 'static-property', + 'property', + 'private-property', + 'constructor', + 'static-method', + 'static-private-method', + ['get-method', 'set-method'], + 'method', + 'private-method', + 'unknown', + ], + order: 'asc', + type: 'alphabetical', + }, ], - "@typescript-eslint/no-var-requires": "off", - "no-unused-expressions": "off", - "node/no-unsupported-features/es-syntax": "off", - "node/no-missing-import": "off", - "import/no-unresolved": "error", - "valid-jsdoc": ["warn", { "requireReturnType": false, "requireParamType": false }] - } + 'valid-jsdoc': ['warn', {requireParamType: false, requireReturnType: false}], + }, + settings: { + 'import/parsers': { + '@typescript-eslint/parser': ['.ts', '.tsx'], + }, + 'import/resolver': { + typescript: { + alwaysTryTypes: true, + }, + }, + }, } diff --git a/package.json b/package.json index 2800fd4..b0cae01 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,11 @@ "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-mocha": "^10.1.0", - "eslint-plugin-node": "^11.1.0" + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-perfectionist": "^2.1.0" }, "devDependencies": { + "@oclif/prettier-config": "^0.2.1", "eslint": "^8.49.0", "typescript": "^4.9.5" }, @@ -34,4 +36,4 @@ "test": "eslint -c index.js .", "build": "echo 'nothing to build!'" } -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 5f50cc2..95f3f46 100644 --- a/yarn.lock +++ b/yarn.lock @@ -79,6 +79,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@oclif/prettier-config@^0.2.1": + version "0.2.1" + resolved "https://registry.yarnpkg.com/@oclif/prettier-config/-/prettier-config-0.2.1.tgz#1def9f38134f9bfb229257f48a35f7d0d183dc78" + integrity sha512-XB8kwQj8zynXjIIWRm+6gO/r8Qft2xKtwBMSmq1JRqtA6TpwpqECqiu8LosBCyg2JBXuUy2lU23/L98KIR7FrQ== + "@types/color-name@^1.1.1": version "1.1.1" resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" @@ -135,6 +140,14 @@ "@typescript-eslint/types" "6.7.2" "@typescript-eslint/visitor-keys" "6.7.2" +"@typescript-eslint/scope-manager@6.7.4": + version "6.7.4" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.7.4.tgz#a484a17aa219e96044db40813429eb7214d7b386" + integrity sha512-SdGqSLUPTXAXi7c3Ob7peAGVnmMoGzZ361VswK2Mqf8UOYcODiYvs8rs5ILqEdfvX1lE7wEZbLyELCW+Yrql1A== + dependencies: + "@typescript-eslint/types" "6.7.4" + "@typescript-eslint/visitor-keys" "6.7.4" + "@typescript-eslint/type-utils@6.7.2": version "6.7.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.7.2.tgz#ed921c9db87d72fa2939fee242d700561454f367" @@ -150,6 +163,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.7.2.tgz#75a615a6dbeca09cafd102fe7f465da1d8a3c066" integrity sha512-flJYwMYgnUNDAN9/GAI3l8+wTmvTYdv64fcH8aoJK76Y+1FCZ08RtI5zDerM/FYT5DMkAc+19E4aLmd5KqdFyg== +"@typescript-eslint/types@6.7.4": + version "6.7.4" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.7.4.tgz#5d358484d2be986980c039de68e9f1eb62ea7897" + integrity sha512-o9XWK2FLW6eSS/0r/tgjAGsYasLAnOWg7hvZ/dGYSSNjCh+49k5ocPN8OmG5aZcSJ8pclSOyVKP2x03Sj+RrCA== + "@typescript-eslint/typescript-estree@6.7.2": version "6.7.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.2.tgz#ce5883c23b581a5caf878af641e49dd0349238c7" @@ -163,6 +181,19 @@ semver "^7.5.4" ts-api-utils "^1.0.1" +"@typescript-eslint/typescript-estree@6.7.4": + version "6.7.4" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.7.4.tgz#f2baece09f7bb1df9296e32638b2e1130014ef1a" + integrity sha512-ty8b5qHKatlNYd9vmpHooQz3Vki3gG+3PchmtsA4TgrZBKWHNjWfkQid7K7xQogBqqc7/BhGazxMD5vr6Ha+iQ== + dependencies: + "@typescript-eslint/types" "6.7.4" + "@typescript-eslint/visitor-keys" "6.7.4" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + "@typescript-eslint/utils@6.7.2": version "6.7.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.7.2.tgz#b9ef0da6f04932167a9222cb4ac59cb187165ebf" @@ -176,6 +207,19 @@ "@typescript-eslint/typescript-estree" "6.7.2" semver "^7.5.4" +"@typescript-eslint/utils@^6.6.0": + version "6.7.4" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.7.4.tgz#2236f72b10e38277ee05ef06142522e1de470ff2" + integrity sha512-PRQAs+HUn85Qdk+khAxsVV+oULy3VkbH3hQ8hxLRJXWBEd7iI+GbQxH5SEUSH7kbEoTp6oT1bOwyga24ELALTA== + dependencies: + "@eslint-community/eslint-utils" "^4.4.0" + "@types/json-schema" "^7.0.12" + "@types/semver" "^7.5.0" + "@typescript-eslint/scope-manager" "6.7.4" + "@typescript-eslint/types" "6.7.4" + "@typescript-eslint/typescript-estree" "6.7.4" + semver "^7.5.4" + "@typescript-eslint/visitor-keys@6.7.2": version "6.7.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.2.tgz#4cb2bd786f1f459731b0ad1584c9f73e1c7a4d5c" @@ -184,6 +228,14 @@ "@typescript-eslint/types" "6.7.2" eslint-visitor-keys "^3.4.1" +"@typescript-eslint/visitor-keys@6.7.4": + version "6.7.4" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.7.4.tgz#80dfecf820fc67574012375859085f91a4dff043" + integrity sha512-pOW37DUhlTZbvph50x5zZCkFn3xzwkGtNoJHzIM3svpiSkJzwOYr/kVBaXmf+RAQiUDs1AHEZVNPg6UJCJpwRA== + dependencies: + "@typescript-eslint/types" "6.7.4" + eslint-visitor-keys "^3.4.1" + acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" @@ -306,6 +358,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" @@ -606,6 +665,15 @@ eslint-plugin-node@^11.1.0: resolve "^1.10.1" semver "^6.1.0" +eslint-plugin-perfectionist@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-perfectionist/-/eslint-plugin-perfectionist-2.1.0.tgz#08809661661d98010cd69de3b6a1e19c8a977cce" + integrity sha512-KVA7H6J/qfmZH/WopNKFgYbKoX+ozKAOIeQvo/+jibn6k9e71Et+giIHEHrMICZ043CeGpRKrCRRhlmD7pjeRg== + dependencies: + "@typescript-eslint/utils" "^6.6.0" + minimatch "^9.0.3" + natural-compare-lite "^1.4.0" + eslint-scope@^7.2.2: version "7.2.2" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" @@ -1203,6 +1271,13 @@ minimatch@^3.0.5, minimatch@^3.1.2: dependencies: brace-expansion "^1.1.7" +minimatch@^9.0.3: + version "9.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825" + integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.0, minimist@^1.2.6: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" @@ -1213,6 +1288,11 @@ ms@2.1.2, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== + natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"