Skip to content

Commit

Permalink
refactor: use new eslint config, get rid of cjs files
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed Sep 13, 2023
1 parent 62d967a commit 5a9c816
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 26 deletions.
7 changes: 1 addition & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -27,18 +27,13 @@
}
}
],
"unicorn/prefer-node-protocol": "error",

/**
* Because our command classes have a `run` method that might not always call `this` we need to
* explicitly exclude `run` from this rule.
*/
"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.
*
Expand Down
9 changes: 5 additions & 4 deletions bin/docker.cjs → bin/docker.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions bin/rdme.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/env node
// eslint-disable-next-line import/extensions
import '../dist/src/cli.js';
8 changes: 3 additions & 5 deletions bin/set-action-image.cjs → bin/set-action-image.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 7 additions & 7 deletions bin/set-major-version-tag.cjs → bin/set-major-version-tag.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions bin/set-version-output.js
Original file line number Diff line number Diff line change
@@ -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';

/**
Expand Down
2 changes: 1 addition & 1 deletion knip.ts
Original file line number Diff line number Diff line change
@@ -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'],
};
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit 5a9c816

Please sign in to comment.