Skip to content

Commit 90166d3

Browse files
ESLint fixes
1 parent 5898a09 commit 90166d3

File tree

11 files changed

+17
-26
lines changed

11 files changed

+17
-26
lines changed

src/cli/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: no-console
21
import { info, success } from "log-symbols";
32
import { manifest } from "../manifest";
43
import { ProgressEvent, VersionBumpProgress } from "../types/version-bump-progress";
@@ -45,7 +44,6 @@ export async function main(args: string[]): Promise<void> {
4544
}
4645

4746
function progress({ event, script, updatedFiles, skippedFiles, newVersion }: VersionBumpProgress): void {
48-
// tslint:disable-next-line: switch-default
4947
switch (event) {
5048
case ProgressEvent.FileUpdated:
5149
console.log(success, `Updated ${updatedFiles.pop()} to ${newVersion}`);

src/cli/parse-args.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: no-console
21
import * as commandLineArgs from "command-line-args";
32
import * as semver from "semver";
43
import { isReleaseType } from "../release-type";
@@ -55,7 +54,7 @@ export function parseArgs(argv: string[]): ParsedArgs {
5554
// If --preid is used without an argument, then throw an error, since it's probably a mistake.
5655
// If they want to use the default value ("beta"), then they should not pass the argument at all
5756
if (args.preid === null) {
58-
throw new Error(`The --preid option requires a value, such as "alpha", "beta", etc.`);
57+
throw new Error("The --preid option requires a value, such as \"alpha\", \"beta\", etc.");
5958
}
6059

6160
// If --commit is used without an argument, then treat it as a boolean flag

src/fs.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ export async function writeJsonFile(file: JsonFile): Promise<void> {
4949
/**
5050
* Reads a text file and returns its contents.
5151
*/
52-
export function readTextFile(name: string, cwd: string): Promise<TextFile> { // tslint:disable-line: promise-function-async
52+
export function readTextFile(name: string, cwd: string): Promise<TextFile> {
5353
return new Promise((resolve, reject) => {
5454
let filePath = path.join(cwd, name);
5555

56-
// tslint:disable-next-line ban
5756
fs.readFile(filePath, "utf8", (err, text) => {
5857
if (err) {
5958
reject(err);
@@ -71,9 +70,8 @@ export function readTextFile(name: string, cwd: string): Promise<TextFile> { //
7170
/**
7271
* Writes the given text to the specified file.
7372
*/
74-
export function writeTextFile(file: TextFile): Promise<void> { // tslint:disable-line: promise-function-async
73+
export function writeTextFile(file: TextFile): Promise<void> {
7574
return new Promise((resolve, reject) => {
76-
// tslint:disable-next-line ban
7775
fs.writeFile(file.path, file.data, (err) => {
7876
if (err) {
7977
reject(err);

src/get-new-version.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as inquirer from "inquirer";
22
import * as semver from "semver";
3-
import { ReleaseType, SemVer } from "semver"; // tslint:disable-line: no-duplicate-imports
3+
import { ReleaseType, SemVer } from "semver";
44
import { BumpRelease, PromptRelease } from "./normalize-options";
55
import { Operation } from "./operation";
66
import { isPrerelease, releaseTypes } from "./release-type";
@@ -46,7 +46,7 @@ function getNextVersion(oldVersion: string, bump: BumpRelease): string {
4646
// This is a special case when going from a non-prerelease version to a prerelease version.
4747
// SemVer sets the prerelease version to zero (e.g. "1.23.456" => "1.23.456-beta.0").
4848
// But the user probably expected it to be "1.23.456-beta.1" instead.
49-
// @ts-ignore
49+
// @ts-expect-error - TypeScript thinks this array is read-only
5050
newSemVer.prerelease[1] = "1";
5151
newSemVer.format();
5252
}

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// tslint:disable: no-default-export
21
import { versionBump } from "./version-bump";
32

43
// Exprot the external type definitions as named exports
@@ -13,5 +12,5 @@ export default versionBump;
1312

1413
// CommonJS default export hack
1514
if (typeof module === "object" && typeof module.exports === "object") {
16-
module.exports = Object.assign(module.exports.default, module.exports); // tslint:disable-line: no-unsafe-any
15+
module.exports = Object.assign(module.exports.default, module.exports);
1716
}

src/manifest.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// NOTE: We can't `import` the package.json file because it's outside of the "src" directory.
2-
// tslint:disable-next-line: no-var-requires no-require-imports
2+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
33
const manifest = require("../package.json") as Manifest;
44

55
export { manifest };
@@ -14,7 +14,6 @@ export interface Manifest {
1414
[key: string]: unknown;
1515
}
1616

17-
// tslint:disable: no-any no-unsafe-any
1817

1918
/**
2019
* Determines whether the specified value is a package manifest.

src/normalize-options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import globby = require("globby"); // tslint:disable-line: no-require-imports
1+
import * as globby from "globby";
22
import { hasMagic } from "globby";
33
import { isReleaseType, ReleaseType } from "./release-type";
44
import { VersionBumpOptions } from "./types/version-bump-options";
@@ -128,7 +128,7 @@ export async function normalizeOptions(raw: VersionBumpOptions): Promise<Normali
128128
}
129129

130130
if (release.type === "prompt" && !(ui.input && ui.output)) {
131-
throw new Error(`Cannot prompt for the version number because input or output has been disabled.`);
131+
throw new Error("Cannot prompt for the version number because input or output has been disabled.");
132132
}
133133

134134
return { release, commit, tag, push, files, cwd, interface: ui };

src/operation.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export class Operation {
8383
// Validate and normalize the options
8484
let options = await normalizeOptions(input);
8585

86-
// tslint:disable-next-line: no-unbound-method
8786
return new Operation(options, input.progress);
8887
}
8988

src/release-type.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const prereleaseTypes: ReleaseType[] = ["premajor", "preminor", "prepatch
1212
*/
1313
export const releaseTypes: ReleaseType[] = prereleaseTypes.concat(["major", "minor", "patch"]);
1414

15-
// tslint:disable: no-any no-unsafe-any
1615

1716
/**
1817
* Determines whether the specified value is a pre-release.

test/specs/api.spec.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ describe("versionBup() API", () => {
3434
expect(files.json("package.json")).to.deep.equal({ version: "2.34.567" });
3535

3636
// Git and NPM should NOT have been called
37-
expect(mocks.git()).to.be.empty;
38-
expect(mocks.npm()).to.be.empty;
37+
expect(mocks.git()).to.have.lengthOf(0);
38+
expect(mocks.npm()).to.have.lengthOf(0);
3939
});
4040

4141
it("should accept a bump type", async () => {
@@ -60,8 +60,8 @@ describe("versionBup() API", () => {
6060
expect(files.json("package.json")).to.deep.equal({ version: "1.1.0" });
6161

6262
// Git and NPM should NOT have been called
63-
expect(mocks.git()).to.be.empty;
64-
expect(mocks.npm()).to.be.empty;
63+
expect(mocks.git()).to.have.lengthOf(0);
64+
expect(mocks.npm()).to.have.lengthOf(0);
6565
});
6666

6767
it("should accept options", async () => {
@@ -124,7 +124,7 @@ describe("versionBup() API", () => {
124124
]);
125125

126126
// NPM should NOT have been called
127-
expect(mocks.npm()).to.be.empty;
127+
expect(mocks.npm()).to.have.lengthOf(0);
128128
});
129129

130130
it("should throw an error if the options are invalid", async () => {
@@ -168,8 +168,8 @@ describe("versionBup() API", () => {
168168
expect(files.json("package.json")).to.deep.equal({ version: "hello world" });
169169

170170
// Git and NPM should NOT have been called
171-
expect(mocks.git()).to.be.empty;
172-
expect(mocks.npm()).to.be.empty;
171+
expect(mocks.git()).to.have.lengthOf(0);
172+
expect(mocks.npm()).to.have.lengthOf(0);
173173
}
174174
});
175175

0 commit comments

Comments
 (0)