refactor: enhance ESLint configuration and type safety

This commit replaces `.eslintrc.yml` with `eslint.config.mts`,
and updates the ESLint setup with Noir and Flat Gitignore configs.

Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
Ardalan Amini committed 2025-06-07 17:27:28 +03:30
1 parent 43d0d5f60d
commit 04e49adbba
32 files changed
+1140 -752

No files matched your search

+4 -4
View File
@@ -22,10 +22,10 @@
* SOFTWARE.
*/
import { commitTypes, defaultCommitType } from "../inputs/index.js";
import { trim } from "../utils/index.js";
import { Node } from "./node.js";
import { TypeNode } from "./type.js";
import { commitTypes, defaultCommitType } from "../inputs/index.js";
import { trim } from "../utils/index.js";
/**
* Represents a changelog node which organizes and processes commit types into structured changelog entries.
@@ -70,14 +70,14 @@ export class ChangelogNode extends Node {
* @returns A concatenated string of all printed types with the applied prefix, or null if no types are available.
*/
public print(prefix = ""): string | null {
const { types } = this;
const { types, typeMap, defaultType } = this;
if (types.size === 0) return null;
/**
* Using this instead of iterating over the `types` values allows the action users to apply their own custom order.
*/
const acceptedTypes = [...new Set(Object.values(this.typeMap).concat(this.defaultType))];
const acceptedTypes = [...new Set([...Object.values(typeMap), ...defaultType])];
const parts: string[] = [];
+6 -9
View File
@@ -22,10 +22,10 @@
* SOFTWARE.
*/
import { mentionAuthors } from "../inputs/index.js";
import { CommitHashNode } from "./commit-hash.js";
import { Node } from "./node.js";
import { PullRequestNode } from "./pull-request.js";
import { mentionAuthors } from "../inputs/index.js";
/**
* Represents a node for a commit author, containing information about the author
@@ -55,18 +55,15 @@ export class CommitAuthorNode extends Node {
* @returns The created reference node, either a CommitHashNode or a PullRequestNode.
*/
public addReference(sha: string, pr?: string): CommitHashNode | PullRequestNode {
let reference: CommitHashNode | PullRequestNode;
// PR references take priority over commit hash references
if (pr) reference = new PullRequestNode(pr);
else reference = new CommitHashNode(sha);
const reference = pr ? new PullRequestNode(pr) : new CommitHashNode(sha);
// Check if a reference already exists to avoid duplicates
for (const existingRef of this.references) {
for (const existingReference of this.references) {
if (
(!pr && existingRef instanceof CommitHashNode && existingRef.sha === sha)
|| (existingRef instanceof PullRequestNode && existingRef.pr === pr)
) return existingRef;
(!pr && existingReference instanceof CommitHashNode && existingReference.sha === sha)
|| (existingReference instanceof PullRequestNode && existingReference.pr === pr)
) return existingReference;
}
this.references.push(reference);
+1 -1
View File
@@ -22,8 +22,8 @@
* SOFTWARE.
*/
import { includeCommitLinks } from "../inputs/index.js";
import { Node } from "./node.js";
import { includeCommitLinks } from "../inputs/index.js";
/**
* Represents a node that holds a commit hash (SHA) and provides functionality
+2 -1
View File
@@ -57,7 +57,8 @@ export class CommitNode extends Node {
// Only reuse authors with known usernames.
if (username && authors.length > 0) {
// Only if the last reference is to the same author, reuse the node.
const previousAuthor = authors[authors.length - 1];
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
const previousAuthor = authors.at(-1)!;
if (previousAuthor.username === username) return previousAuthor;
}
+1 -1
View File
@@ -23,9 +23,9 @@
*/
export * from "./changelog.js";
export * from "./commit.js";
export * from "./commit-author.js";
export * from "./commit-hash.js";
export * from "./commit.js";
export * from "./node.js";
export * from "./pull-request.js";
export * from "./scope.js";
+1 -1
View File
@@ -22,8 +22,8 @@
* SOFTWARE.
*/
import { includePRLinks } from "../inputs/index.js";
import { Node } from "./node.js";
import { includePRLinks } from "../inputs/index.js";
/**
* Represents a node associated with a pull request or issue link.
+1 -1
View File
@@ -22,9 +22,9 @@
* SOFTWARE.
*/
import { trim } from "../utils/index.js";
import { Node } from "./node.js";
import { ScopeNode } from "./scope.js";
import { trim } from "../utils/index.js";
/**
* Represents a node for a specific type that manages associated scopes.