Skip to content

Commit

Permalink
chore: linter and current standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Apr 19, 2023
1 parent 70adb48 commit 67f06a8
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 17 deletions.
12 changes: 1 addition & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
// See more at https://github.com/forcedotcom/sfdx-dev-packages/tree/master/packages/dev-scripts

module.exports = {
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license'],
rules: {
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'jsdoc/check-indentation': 'off',
'@typescript-eslint/prefer-regexp-exec': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/camelcase': 'off',
'no-underscore-dangle': 'off',
'@typescript-eslint/require-await': 'off',
},
extends: ['eslint-config-salesforce-typescript', 'eslint-config-salesforce-license', 'plugin:sf-plugin/library'],
root: true,
};
4 changes: 3 additions & 1 deletion messages/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ This command is currently in beta. Any aspect of this command can change without

# error.InvalidArgumentFormat

Set varargs with this format: key=value or key="value with spaces".
Error in the following argument
%s
Set varargs with this format: key=value or key="value with spaces"

# error.DuplicateArgument

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsdoc": "^40.3.0",
"eslint-plugin-sf-plugin": "^1.15.1",
"husky": "^7.0.4",
"mocha": "^9.1.3",
"nyc": "^15.1.0",
Expand Down Expand Up @@ -144,4 +145,4 @@
"output": []
}
}
}
}
2 changes: 2 additions & 0 deletions src/flags/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export type DurationFlagConfig = {
* ```
*/
export const durationFlag = Flags.custom<Duration, DurationFlagConfig>({
// eslint-disable-next-line @typescript-eslint/require-await
parse: async (input, _, opts) => validate(input, opts),
// eslint-disable-next-line @typescript-eslint/require-await
default: async (context) =>
context.options.defaultValue ? toDuration(context.options.defaultValue, context.options.unit) : undefined,
});
Expand Down
3 changes: 2 additions & 1 deletion src/flags/salesforceId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type IdFlagConfig = {
* ```
*/
export const salesforceIdFlag = Flags.custom<string, IdFlagConfig>({
// eslint-disable-next-line @typescript-eslint/require-await
parse: async (input, _ctx, opts) => validate(input, opts),
char: 'i',
});
Expand All @@ -52,7 +53,7 @@ const validate = (input: string, config?: IdFlagConfig): string => {
const { length, startsWith } = config ?? {};

// If the flag doesn't specify a length or specifies "both", then let it accept both 15 or 18.
const allowedIdLength = (!length || length === 'both') ? [15, 18] : [length];
const allowedIdLength = !length || length === 'both' ? [15, 18] : [length];

if (!allowedIdLength.includes(input.length)) {
throw messages.createError('errors.InvalidIdLength', [
Expand Down
1 change: 1 addition & 0 deletions src/stubUx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
/* eslint-disable @typescript-eslint/explicit-function-return-type */

import { SinonSandbox } from 'sinon';
import { SfCommand } from './sfCommand';
Expand Down
10 changes: 7 additions & 3 deletions test/unit/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ import {
OrgConfigProperties,
SfdxPropertyKeys,
SFDX_ALLOWED_PROPERTIES,
Messages,
} from '@salesforce/core';
import { parseVarArgs, toHelpSection } from '../../src/util';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@salesforce/sf-plugins-core', 'messages');

describe('toHelpSection', () => {
it('should produce help section for env vars', () => {
const envVarSection = toHelpSection('ENV VAR SECTION', EnvironmentVariable.SFDX_ACCESS_TOKEN);
Expand Down Expand Up @@ -114,9 +118,9 @@ describe('parseVarArgs', () => {
});

it('should throw if invalid format', () => {
expect(() => parseVarArgs({ arg1: 'foobar' }, ['foobar', 'key1=value1', 'key2:value2'])).to.throw(
'Set varargs with this format: key=value or key="value with spaces". key2:value2'
);
const badArg = 'key2:value2';
const expectedError = messages.createError('error.InvalidArgumentFormat', [badArg]).message;
expect(() => parseVarArgs({ arg1: 'foobar' }, ['foobar', 'key1=value1', badArg])).to.throw(expectedError);
});

it('should throw if duplicates exist', () => {
Expand Down
56 changes: 56 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,14 @@
"@typescript-eslint/types" "5.58.0"
"@typescript-eslint/visitor-keys" "5.58.0"

"@typescript-eslint/[email protected]":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.0.tgz#86501d7a17885710b6716a23be2e93fc54a4fe8c"
integrity sha512-tsoldKaMh7izN6BvkK6zRMINj4Z2d6gGhO2UsI8zGZY3XhLq1DndP3Ycjhi1JwdwPRwtLMW4EFPgpuKhbCGOvQ==
dependencies:
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/visitor-keys" "5.59.0"

"@typescript-eslint/[email protected]":
version "5.44.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.44.0.tgz#bc5a6e8a0269850714a870c9268c038150dfb3c7"
Expand All @@ -1284,6 +1292,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.58.0.tgz#54c490b8522c18986004df7674c644ffe2ed77d8"
integrity sha512-JYV4eITHPzVQMnHZcYJXl2ZloC7thuUHrcUmxtzvItyKPvQ50kb9QXBkgNAt90OYMqwaodQh2kHutWZl1fc+1g==

"@typescript-eslint/[email protected]":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.0.tgz#3fcdac7dbf923ec5251545acdd9f1d42d7c4fe32"
integrity sha512-yR2h1NotF23xFFYKHZs17QJnB51J/s+ud4PYU4MqdZbzeNxpgUr05+dNeCN/bb6raslHvGdd6BFCkVhpPk/ZeA==

"@typescript-eslint/[email protected]":
version "5.44.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.44.0.tgz#0461b386203e8d383bb1268b1ed1da9bc905b045"
Expand All @@ -1310,6 +1323,19 @@
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.0.tgz#8869156ee1dcfc5a95be3ed0e2809969ea28e965"
integrity sha512-sUNnktjmI8DyGzPdZ8dRwW741zopGxltGs/SAPgGL/AAgDpiLsCFLcMNSpbfXfmnNeHmK9h3wGmCkGRGAoUZAg==
dependencies:
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/visitor-keys" "5.59.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"

"@typescript-eslint/[email protected]":
version "5.44.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.44.0.tgz#d733da4d79d6c30f1a68b531cdda1e0c1f00d52d"
Expand All @@ -1324,6 +1350,20 @@
eslint-utils "^3.0.0"
semver "^7.3.7"

"@typescript-eslint/utils@^5.58.0":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.0.tgz#063d066b3bc4850c18872649ed0da9ee72d833d5"
integrity sha512-GGLFd+86drlHSvPgN/el6dRQNYYGOvRSDVydsUaQluwIW3HvbXuxyuD5JETvBt/9qGYe+lOrDk6gRrWOHb/FvA==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@types/json-schema" "^7.0.9"
"@types/semver" "^7.3.12"
"@typescript-eslint/scope-manager" "5.59.0"
"@typescript-eslint/types" "5.59.0"
"@typescript-eslint/typescript-estree" "5.59.0"
eslint-scope "^5.1.1"
semver "^7.3.7"

"@typescript-eslint/[email protected]":
version "5.44.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.44.0.tgz#10740dc28902bb903d12ee3a005cc3a70207d433"
Expand All @@ -1340,6 +1380,14 @@
"@typescript-eslint/types" "5.58.0"
eslint-visitor-keys "^3.3.0"

"@typescript-eslint/[email protected]":
version "5.59.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.0.tgz#a59913f2bf0baeb61b5cfcb6135d3926c3854365"
integrity sha512-qZ3iXxQhanchCeaExlKPV3gDQFxMUmU35xfd5eCXB6+kUw1TUAbIy2n7QIrwz9s98DQLzNWyHp61fY0da4ZcbA==
dependencies:
"@typescript-eslint/types" "5.59.0"
eslint-visitor-keys "^3.3.0"

"@ungap/[email protected]":
version "1.1.2"
resolved "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
Expand Down Expand Up @@ -2907,6 +2955,14 @@ eslint-plugin-prefer-arrow@^1.2.1:
resolved "https://registry.npmjs.org/eslint-plugin-prefer-arrow/-/eslint-plugin-prefer-arrow-1.2.3.tgz#e7fbb3fa4cd84ff1015b9c51ad86550e55041041"
integrity sha512-J9I5PKCOJretVuiZRGvPQxCbllxGAV/viI20JO3LYblAodofBxyMnZAJ+WGeClHgANnSJberTNoFWWjrWKBuXQ==

eslint-plugin-sf-plugin@^1.15.1:
version "1.15.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-sf-plugin/-/eslint-plugin-sf-plugin-1.15.1.tgz#c922cd4825d118fcfcb4b20629d9d65b0d394d89"
integrity sha512-D2i0EiQfTOjVNPivS2Bib/YsLS+l+QU5i72NT4Lhn4nSCTb5VS19PP7lLjlFlW5ffg552q7li3BMM6Cs75YQgw==
dependencies:
"@salesforce/core" "^3.34.6"
"@typescript-eslint/utils" "^5.58.0"

eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down

0 comments on commit 67f06a8

Please sign in to comment.