Skip to content

Commit

Permalink
chore: update dependencies and use new eslint/ts configs (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken authored Jan 2, 2025
1 parent 4b32b1d commit 984bb7c
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 59 deletions.
11 changes: 0 additions & 11 deletions .eslintrc

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -65,7 +65,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -78,6 +78,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ jobs:

steps:
- name: "Checkout code"
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand All @@ -59,14 +59,14 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@4fa2a7953630fd2f3fb380f21be14ede0169dd4f # v3.25.12
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
sarif_file: results.sarif
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { typescriptConfig } from "@openally/config.eslint";

export default typescriptConfig();
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
"import": "./dist/index.js"
}
},
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
"prepublishOnly": "npm run build",
"test-only": "npx tsx --test test/Spinner.spec.ts",
"test-only": "tsx --test test/Spinner.spec.ts",
"test": "npm run lint && npm run coverage",
"coverage": "c8 -r html npm run test-only",
"lint": "eslint ."
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,15 +48,15 @@
"dependencies": {
"@topcli/wcwidth": "^1.0.1",
"ansi-regex": "^6.0.1",
"cli-cursor": "^4.0.0",
"cli-cursor": "^5.0.0",
"cli-spinners": "^3.1.0",
"kleur": "^4.1.5",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"@nodesecure/eslint-config": "^1.9.0",
"@slimio/is": "^2.0.0",
"@types/node": "^20.14.11",
"@openally/config.eslint": "^1.1.0",
"@openally/config.typescript": "^1.0.3",
"@types/node": "^22.10.2",
"c8": "^10.1.2",
"tsup": "^8.1.0",
"tsx": "^4.16.2",
Expand Down
12 changes: 6 additions & 6 deletions src/Spinner.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import readline from "node:readline";
import * as TTY from "node:tty";

// Import Third-party Dependencies
import cliSpinners, { type SpinnerName, type Spinner as CliSpinner } from "cli-spinners";
import * as cliSpinners from "cli-spinners";
import stripAnsi from "strip-ansi";
import ansiRegex from "ansi-regex";
import wcwidth from "@topcli/wcwidth";
Expand All @@ -15,7 +15,7 @@ import kleur from "kleur";
let internalSpinnerCount = 0;

// CONSTANTS
const kDefaultSpinnerName = "dots" satisfies SpinnerName;
const kDefaultSpinnerName = "dots" satisfies cliSpinners.SpinnerName;
const kLogSymbols = process.platform !== "win32" || process.env.CI || process.env.TERM === "xterm-256color" ?
{ success: kleur.bold().green("✔"), error: kleur.bold().red("✖") } :
{ success: kleur.bold().green("√"), error: kleur.bold().red("×") };
Expand All @@ -26,7 +26,7 @@ export interface ISpinnerOptions {
*
* @default "dots"
*/
name?: SpinnerName;
name?: cliSpinners.SpinnerName;
/**
* Spinner frame color
*
Expand Down Expand Up @@ -54,7 +54,7 @@ export class Spinner extends EventEmitter {

#verbose = true;
#started = false;
#spinner: CliSpinner;
#spinner: cliSpinners.Spinner;
#text = "";
#prefix = "";
#color: (stdout: string) => string;
Expand Down Expand Up @@ -124,7 +124,7 @@ export class Spinner extends EventEmitter {
const terminalCol = this.stream.columns;
const defaultRaw = `${this.#getSpinnerFrame(spinnerSymbol)} ${this.#prefix}${this.text}`;

let regexArray: any[] = [];
let regexArray: any[];
let count = 0;
while (1) {
regexArray = defaultRaw
Expand All @@ -135,7 +135,7 @@ export class Spinner extends EventEmitter {
}
count = regexArray.length;
}
count += regexArray.reduce((prev, curr) => prev + wcwidth(curr), 0);
count += regexArray!.reduce((prev, curr) => prev + wcwidth(curr), 0);

return wcwidth(stripAnsi(defaultRaw)) > terminalCol ?
`${defaultRaw.slice(0, terminalCol + count)}\x1B[0m` :
Expand Down
7 changes: 5 additions & 2 deletions src/computeWithSpinner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Import Internal Dependencies
import { Spinner, ISpinnerOptions } from "./Spinner.class.js";
import {
Spinner,
type ISpinnerOptions
} from "./Spinner.class.js";

// CONSTANTS
// eslint-disable-next-line func-style
Expand Down Expand Up @@ -31,7 +34,7 @@ export async function computeWithSpinner<T = void>(

return response;
}
catch (err) {
catch (err: any) {
spinner.failed(fail(err));

throw err;
Expand Down
7 changes: 0 additions & 7 deletions test/Spinner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@ import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { once } from "node:events";

// Import Third-party Dependencies
import is from "@slimio/is";

// Import Internal Dependencies
import { Spinner } from "../src/index.js";

describe("Spinner", () => {
it("should export a JavaScript class", () => {
assert.ok(is.classObject(Spinner));
});

describe("reset", () => {
it("should exist", () => {
assert.ok(typeof Spinner.reset === "function");
Expand Down
16 changes: 3 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
{
"extends": "@openally/config.typescript",
"compilerOptions": {
"declaration": true,
"strictNullChecks": true,
"target": "ES2021",
"outDir": "dist",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"resolveJsonModule": true,
"skipDefaultLibCheck": true,
"forceConsistentCasingInFileNames": true,
"sourceMap": true,
"rootDir": "./src",
"types": ["node"]
"rootDir": "./",
},
"include": ["src", "src/schema/**/*.json"],
"include": ["src", "index.ts"],
"exclude": ["node_modules", "dist"]
}

0 comments on commit 984bb7c

Please sign in to comment.