Skip to content

Commit

Permalink
refactor: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
okize committed Oct 17, 2023
1 parent c3e65c9 commit 0811f48
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
12 changes: 11 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
extends: ['@wistia/eslint-config/base'],
extends: ['@wistia/eslint-config'],
env: {
node: true,
},
Expand All @@ -10,5 +10,15 @@ module.exports = {
},
rules: {
'import/extensions': ['error', 'always'],
'import/no-unused-modules': 'off',
},
overrides: [
// test files
{
files: ['*.test.mjs'],
rules: {
'id-length': ['error', { exceptions: ['t'] }],
},
},
],
};
20 changes: 9 additions & 11 deletions helpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export const getGithubClient = (githubToken) => {
};

// returns just the beginning X.X.X part of the version
export const getTrimmedPackageVersion = (version) =>
version.trim().split(/[.-]/).slice(0, 3).join('.');
export const getTrimmedPackageVersion = (version) => version.trim().split(/[.-]/).slice(0, 3).join('.');

// current version + 8 chars of a UUID + 7 chars of the commit hash
// must be valid semver https://semver.org/
Expand All @@ -75,24 +74,23 @@ export const getUniqueVersion = (currentVersion) => {
};

// set auth token to allow publishing in CI
export const getNpmAuthCommand = (npmToken) =>
`npm config set //registry.npmjs.org/:_authToken ${npmToken}`;
export const getNpmAuthCommand = (npmToken) => `npm config set //registry.npmjs.org/:_authToken ${npmToken}`;

// updates version in package.json
export const getUpdatePackageVersionCommand = (uniqueVersion) =>
`npm version --git-tag-version false ${uniqueVersion}`;
export const getUpdatePackageVersionCommand = (uniqueVersion) => `npm version --git-tag-version false ${uniqueVersion}`;

// Converts a boolean string value `value` into a boolean. If passed something other than 'true' or 'false' will coerce value to boolean.
export function coerceToBoolean(value) {
// Converts a boolean string value `value` into a boolean.
// If passed something other than 'true' or 'false' will coerce value to boolean.
export const coerceToBoolean = (value) => {
if (value === 'true' || value === 'false') {
return value === 'true';
}
return Boolean(value);
}
};

// publish with "beta" tag since if we do not specify a tag, "latest" will be used by default
export const getPublishPackageCommand = (isDryRun) => {
let publishCommand = `npm publish --verbose --tag beta`;
let publishCommand = 'npm publish --verbose --tag beta';

if (coerceToBoolean(isDryRun)) {
publishCommand = `${publishCommand} --dry-run`;
Expand Down Expand Up @@ -124,7 +122,7 @@ export const loadPackageJson = () => {
return { name, currentVersion };
};

// returns GitHub-flavored markdown with some instructions on how to install a branch package with npm & yarn
// returns GitHub-flavored markdown with some instructions on how to install a branch package
// GitHub doesn't allow text colors in markdown so we use the diff code-colorization
// to get a light grey for displaying date & time
export const generateInstallationInstructionsMarkdown = (
Expand Down
1 change: 0 additions & 1 deletion helpers.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import test from 'ava'; // eslint-disable-line import/no-unresolved

import {
coerceToBoolean,
generateInstallationInstructionsMarkdown,
Expand Down
1 change: 0 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import core from '@actions/core';

import {
getUniqueVersion,
loadPackageJson,
Expand Down

0 comments on commit 0811f48

Please sign in to comment.