Skip to content

Commit

Permalink
devDeps: bump eslint packages (#147)
Browse files Browse the repository at this point in the history
* devDeps: bump @typescript-eslint/ packages

* devDeps: [email protected]>27.1.5

* devDeps: [email protected]>39.6.2

* devDeps: [email protected]>8.40.0

* devDeps: [email protected]>2.2.8

* bump @types/node

* lint:fix

* lint: address lint errors after upgrade



* Bump @metamask/eslint-config from 10.0.0 to 11.1.0

Bumps [@metamask/eslint-config](https://github.com/MetaMask/eslint-config) from 10.0.0 to 11.1.0.
- [Release notes](https://github.com/MetaMask/eslint-config/releases)
- [Commits](MetaMask/eslint-config@v10.0.0...v11.1.0)

---
updated-dependencies:
- dependency-name: "@metamask/eslint-config"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @metamask/eslint-config-jest from 10.0.0 to 11.1.0

Bumps [@metamask/eslint-config-jest](https://github.com/MetaMask/eslint-config) from 10.0.0 to 11.1.0.
- [Release notes](https://github.com/MetaMask/eslint-config/releases)
- [Commits](MetaMask/eslint-config@v10.0.0...v11.1.0)

---
updated-dependencies:
- dependency-name: "@metamask/eslint-config-jest"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @metamask/eslint-config-nodejs from 10.0.0 to 11.1.0

Bumps [@metamask/eslint-config-nodejs](https://github.com/MetaMask/eslint-config) from 10.0.0 to 11.1.0.
- [Release notes](https://github.com/MetaMask/eslint-config/releases)
- [Commits](MetaMask/eslint-config@v10.0.0...v11.1.0)

---
updated-dependencies:
- dependency-name: "@metamask/eslint-config-nodejs"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @metamask/eslint-config-typescript from 10.0.0 to 11.1.0

Bumps [@metamask/eslint-config-typescript](https://github.com/MetaMask/eslint-config) from 10.0.0 to 11.1.0.
- [Release notes](https://github.com/MetaMask/eslint-config/releases)
- [Commits](MetaMask/eslint-config@v10.0.0...v11.1.0)

---
updated-dependencies:
- dependency-name: "@metamask/eslint-config-typescript"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
legobeat and dependabot[bot] authored May 10, 2023
1 parent 839be83 commit f9c09aa
Show file tree
Hide file tree
Showing 11 changed files with 287 additions and 679 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@
},
"devDependencies": {
"@lavamoat/allow-scripts": "^2.1.0",
"@metamask/eslint-config": "^10.0.0",
"@metamask/eslint-config-jest": "^10.0.0",
"@metamask/eslint-config-nodejs": "^10.0.0",
"@metamask/eslint-config-typescript": "^10.0.0",
"@metamask/eslint-config": "^11.1.0",
"@metamask/eslint-config-jest": "^11.1.0",
"@metamask/eslint-config-nodejs": "^11.1.0",
"@metamask/eslint-config-typescript": "^11.1.0",
"@types/cross-spawn": "^6.0.2",
"@types/diff": "^5.0.0",
"@types/jest": "^26.0.23",
"@types/semver": "^7.3.6",
"@types/yargs": "^16.0.1",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"eslint": "^8.26.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.8.2",
"eslint-plugin-jsdoc": "^39.3.25",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^26.4.2",
"outdent": "^0.8.0",
"prettier": "^2.2.1",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.6",
"typescript": "~4.8.4"
Expand Down
50 changes: 25 additions & 25 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ type AddChangeOptions = {
* formatting, update a changelog, or build one from scratch.
*/
export default class Changelog {
private _releases: ReleaseMetadata[];
readonly #releases: ReleaseMetadata[];

private _changes: ChangelogChanges;
#changes: ChangelogChanges;

private _repoUrl: string;
readonly #repoUrl: string;

private _tagPrefix: string;
readonly #tagPrefix: string;

/**
* Construct an empty changelog.
Expand All @@ -271,10 +271,10 @@ export default class Changelog {
repoUrl: string;
tagPrefix?: string;
}) {
this._releases = [];
this._changes = { [unreleased]: {} };
this._repoUrl = repoUrl;
this._tagPrefix = tagPrefix;
this.#releases = [];
this.#changes = { [unreleased]: {} };
this.#repoUrl = repoUrl;
this.#tagPrefix = tagPrefix;
}

/**
Expand All @@ -297,16 +297,16 @@ export default class Changelog {
throw new Error('Version required');
} else if (semver.valid(version) === null) {
throw new Error(`Not a valid semver version: '${version}'`);
} else if (this._changes[version]) {
} else if (this.#changes[version]) {
throw new Error(`Release already exists: '${version}'`);
}

this._changes[version] = {};
this.#changes[version] = {};
const newRelease = { version, date, status };
if (addToStart) {
this._releases.unshift(newRelease);
this.#releases.unshift(newRelease);
} else {
this._releases.push(newRelease);
this.#releases.push(newRelease);
}
}

Expand Down Expand Up @@ -335,13 +335,13 @@ export default class Changelog {
throw new Error(`Unrecognized category: '${category}'`);
} else if (!description) {
throw new Error('Description required');
} else if (version !== undefined && !this._changes[version]) {
} else if (version !== undefined && !this.#changes[version]) {
throw new Error(`Specified release version does not exist: '${version}'`);
}

const release = version
? this._changes[version]
: this._changes[unreleased];
? this.#changes[version]
: this.#changes[unreleased];

if (!release[category]) {
release[category] = [];
Expand All @@ -365,12 +365,12 @@ export default class Changelog {
* @param version - The release version to migrate unreleased changes to.
*/
migrateUnreleasedChangesToRelease(version: Version) {
const releaseChanges = this._changes[version];
const releaseChanges = this.#changes[version];
if (!releaseChanges) {
throw new Error(`Specified release version does not exist: '${version}'`);
}

const unreleasedChanges = this._changes[unreleased];
const unreleasedChanges = this.#changes[unreleased];

for (const category of Object.keys(unreleasedChanges) as ChangeCategory[]) {
if (releaseChanges[category]) {
Expand All @@ -382,7 +382,7 @@ export default class Changelog {
releaseChanges[category] = unreleasedChanges[category];
}
}
this._changes[unreleased] = {};
this.#changes[unreleased] = {};
}

/**
Expand All @@ -391,7 +391,7 @@ export default class Changelog {
* @returns The metadata for each release.
*/
getReleases() {
return this._releases;
return this.#releases;
}

/**
Expand Down Expand Up @@ -429,7 +429,7 @@ export default class Changelog {
* @returns The changes included in the given released.
*/
getReleaseChanges(version: Version) {
return this._changes[version];
return this.#changes[version];
}

/**
Expand All @@ -438,7 +438,7 @@ export default class Changelog {
* @returns The changes that have not yet been released.
*/
getUnreleasedChanges() {
return this._changes[unreleased];
return this.#changes[unreleased];
}

/**
Expand All @@ -450,12 +450,12 @@ export default class Changelog {
return `${changelogTitle}
${changelogDescription}
${stringifyReleases(this._releases, this._changes)}
${stringifyReleases(this.#releases, this.#changes)}
${stringifyLinkReferenceDefinitions(
this._repoUrl,
this._tagPrefix,
this._releases,
this.#repoUrl,
this.#tagPrefix,
this.#releases,
)}`;
}
}
17 changes: 5 additions & 12 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@

import { promises as fs, constants as fsConstants } from 'fs';
import path from 'path';
// Intentionally shadowing 'URL' global, which is equivalent
// Can't use global directly because of missing type, see:
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/34960
// eslint-disable-next-line @typescript-eslint/no-shadow
import { URL } from 'url';
import semver from 'semver';
import yargs from 'yargs/yargs';
import type { Argv } from 'yargs';
import { hideBin } from 'yargs/helpers';
import yargs from 'yargs/yargs';

import { updateChangelog } from './update-changelog';
import { unreleased, Version } from './constants';
import { generateDiff } from './generate-diff';
import { createEmptyChangelog } from './init';

import { unreleased, Version } from './constants';

import { getRepositoryUrl } from './repo';
import { updateChangelog } from './update-changelog';
import {
ChangelogFormattingError,
InvalidChangelogError,
validateChangelog,
} from './validate-changelog';
import { getRepositoryUrl } from './repo';

const updateEpilog = `New commits will be added to the "${unreleased}" section (or \
to the section for the current release if the '--rc' flag is used) in reverse \
Expand Down Expand Up @@ -211,7 +204,7 @@ type InitOptions = {
* @param options.tagPrefix - The prefix used in tags before the version number.
*/
async function init({ changelogPath, repoUrl, tagPrefix }: InitOptions) {
const changelogContent = await createEmptyChangelog({ repoUrl, tagPrefix });
const changelogContent = createEmptyChangelog({ repoUrl, tagPrefix });
await saveChangelog(changelogPath, changelogContent);
}

Expand Down
1 change: 1 addition & 0 deletions src/generate-diff.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _outdent from 'outdent';

import { generateDiff } from './generate-diff';

const outdent = _outdent({ trimTrailingNewline: false });
Expand Down
1 change: 1 addition & 0 deletions src/parse-changelog.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _outdent from 'outdent';

import { parseChangelog } from './parse-changelog';

const outdent = _outdent({ trimTrailingNewline: false });
Expand Down
1 change: 1 addition & 0 deletions src/parse-changelog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import semver from 'semver';

import Changelog from './changelog';
import { ChangeCategory, unreleased } from './constants';

Expand Down
1 change: 1 addition & 0 deletions src/repo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable node/no-process-env */

import path from 'path';

import { getRepositoryUrl } from './repo';

describe('getRepositoryUrl', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/repo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable node/no-process-env, node/no-sync */

import path from 'path';
import fs from 'fs';
import path from 'path';

type PackageJson = {
repository:
Expand Down
15 changes: 9 additions & 6 deletions src/update-changelog.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { strict as assert } from 'assert';
import execa from 'execa';
import { parseChangelog } from './parse-changelog';
import { ChangeCategory, Version } from './constants';

import type Changelog from './changelog';
import { ChangeCategory, Version } from './constants';
import { parseChangelog } from './parse-changelog';

/**
* Get the most recent tag for a project.
Expand Down Expand Up @@ -70,7 +71,7 @@ async function getCommits(commitHashes: string[]) {
if (matchResults) {
// Squash & Merge: the commit subject is parsed as `<description> (#<PR ID>)`
prNumber = matchResults[1];
description = subject.match(/^(.+)\s\(#\d+\)/u)?.[1] || '';
description = subject.match(/^(.+)\s\(#\d+\)/u)?.[1] ?? '';
} else {
// Merge: the PR ID is parsed from the git subject (which is of the form `Merge pull request
// #<PR ID> from <branch>`, and the description is assumed to be the first line of the body.
Expand Down Expand Up @@ -125,8 +126,10 @@ function getAllLoggedPrNumbers(changelog: Changelog) {

const prNumbersWithChangelogEntries = [];
for (const description of changeDescriptions) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const matchResults = description!.matchAll(/\[#(\d+)\]/gu);
if (!description) {
continue;
}
const matchResults = description.matchAll(/\[#(\d+)\]/gu);
const prNumbers = Array.from(matchResults, (result) => result[1]);
prNumbersWithChangelogEntries.push(...prNumbers);
}
Expand Down Expand Up @@ -209,7 +212,7 @@ export async function updateChangelog({

if (
isReleaseCandidate &&
mostRecentTag === `${tagPrefixes[0]}${currentVersion}`
mostRecentTag === `${tagPrefixes[0]}${currentVersion || ''}`
) {
throw new Error(
`Current version already has tag, which is unexpected for a release candidate.`,
Expand Down
6 changes: 2 additions & 4 deletions src/validate-changelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ describe('validateChangelog', () => {
});

it('should throw when a change category is unrecognized', () => {
const changelogWithUnrecognizedChangeCategory = changelogWithReleases.replace(
'### Changed',
'### Updated',
);
const changelogWithUnrecognizedChangeCategory =
changelogWithReleases.replace('### Changed', '### Updated');
expect(() =>
validateChangelog({
changelogContent: changelogWithUnrecognizedChangeCategory,
Expand Down
Loading

0 comments on commit f9c09aa

Please sign in to comment.