diff --git a/.eslintrc b/.eslintrc index 6d126e032..b7d1e9292 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "extends": ["plugin:require-extensions/recommended", "@readme/eslint-config", "@readme/eslint-config/typescript"], + "extends": ["@readme/eslint-config", "@readme/eslint-config/typescript", "@readme/eslint-config/esm"], "root": true, "overrides": [ { @@ -27,7 +27,6 @@ } } ], - "unicorn/prefer-node-protocol": "error", /** * Because our command classes have a `run` method that might not always call `this` we need to @@ -35,10 +34,6 @@ */ "class-methods-use-this": ["error", { "exceptMethods": ["run"] }], - "import/extensions": ["off"], - - "import/no-commonjs": ["error"], - /** * This is a small rule to prevent us from using console.log() statements in our commands. * diff --git a/bin/docker.cjs b/bin/docker.js similarity index 92% rename from bin/docker.cjs rename to bin/docker.js index 4d40a4293..0d34b8c80 100755 --- a/bin/docker.cjs +++ b/bin/docker.js @@ -1,9 +1,10 @@ #! /usr/bin/env node /* eslint-disable no-console */ -/* eslint-disable import/no-commonjs */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const util = require('node:util'); -const execFile = util.promisify(require('node:child_process').execFile); + +import { execFile as unpromisifiedExecFile } from 'node:child_process'; +import util from 'node:util'; + +const execFile = util.promisify(unpromisifiedExecFile); /** * Retrieves and parses the docker image metadata diff --git a/bin/rdme.js b/bin/rdme.js index ae3351534..eba9ca571 100755 --- a/bin/rdme.js +++ b/bin/rdme.js @@ -1,2 +1,3 @@ #!/usr/bin/env node +// eslint-disable-next-line import/extensions import '../dist/src/cli.js'; diff --git a/bin/set-action-image.cjs b/bin/set-action-image.js similarity index 82% rename from bin/set-action-image.cjs rename to bin/set-action-image.js index 59211bdae..a2e6fae4f 100755 --- a/bin/set-action-image.cjs +++ b/bin/set-action-image.js @@ -1,12 +1,10 @@ #! /usr/bin/env node -/* eslint-disable import/no-commonjs */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const fs = require('node:fs/promises'); +import fs from 'node:fs/promises'; // eslint-disable-next-line import/no-extraneous-dependencies -const jsYaml = require('js-yaml'); +import jsYaml from 'js-yaml'; -const pkg = require('../package.json'); +import pkg from '../package.json' assert { type: 'json' }; /** * Updates our `action.yml` file so it properly points to diff --git a/bin/set-major-version-tag.cjs b/bin/set-major-version-tag.js similarity index 82% rename from bin/set-major-version-tag.cjs rename to bin/set-major-version-tag.js index 418a655fb..0a4bef4d4 100755 --- a/bin/set-major-version-tag.cjs +++ b/bin/set-major-version-tag.js @@ -1,12 +1,12 @@ #! /usr/bin/env node -/* eslint-disable import/no-commonjs */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const util = require('node:util'); -const execFile = util.promisify(require('node:child_process').execFile); +import { execFile as unpromisifiedExecFile } from 'node:child_process'; +import util from 'node:util'; -const semverParse = require('semver/functions/parse'); +import { parse } from 'semver'; -const pkg = require('../package.json'); +import pkg from '../package.json' assert { type: 'json' }; + +const execFile = util.promisify(unpromisifiedExecFile); /** * Runs command and logs all output @@ -36,7 +36,7 @@ async function runGitCmd(args) { */ async function setMajorVersionTag() { try { - const parsedVersion = semverParse(pkg.version); + const parsedVersion = parse(pkg.version); if (parsedVersion.prerelease.length) { // eslint-disable-next-line no-console diff --git a/bin/set-version-output.js b/bin/set-version-output.js index 901eb4c9a..8cae398c9 100755 --- a/bin/set-version-output.js +++ b/bin/set-version-output.js @@ -1,6 +1,7 @@ #! /usr/bin/env node import * as core from '@actions/core'; +// eslint-disable-next-line import/extensions import { getNodeVersion, getMajorPkgVersion } from '../dist/src/lib/getPkgVersion.js'; /** diff --git a/knip.ts b/knip.ts index 100d3d5f2..439c5c8d9 100644 --- a/knip.ts +++ b/knip.ts @@ -1,7 +1,7 @@ import type { KnipConfig } from 'knip'; const config: KnipConfig = { - ignore: ['bin/*.cjs', 'bin/*.js', 'vitest.single-threaded.config.ts'], + ignore: ['bin/*.js', 'vitest.single-threaded.config.ts'], ignoreBinaries: ['semantic-release'], ignoreDependencies: ['editor'], }; diff --git a/package-lock.json b/package-lock.json index ead594e9f..f5172baf3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,6 @@ "ajv": "^8.11.0", "alex": "^11.0.0", "eslint": "^8.47.0", - "eslint-plugin-require-extensions": "^0.1.3", "headers-polyfill": "^3.1.2", "husky": "^8.0.0", "js-yaml": "^4.1.0", diff --git a/package.json b/package.json index 95d5663b0..03eae0f8d 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,6 @@ "ajv": "^8.11.0", "alex": "^11.0.0", "eslint": "^8.47.0", - "eslint-plugin-require-extensions": "^0.1.3", "headers-polyfill": "^3.1.2", "husky": "^8.0.0", "js-yaml": "^4.1.0", @@ -105,7 +104,7 @@ "build": "tsc", "debug": "ts-node src/cli.ts", "lint": "alex . && knip && npm run lint:ts && npm run prettier && npm run schemas:check", - "lint:ts": "eslint . --ext .js,.ts,.cjs,.mjs", + "lint:ts": "eslint . --ext .js,.ts,.mjs", "prebuild": "rm -rf dist/", "prepack": "npm run build", "prepare": "husky install",