Skip to content

Commit

Permalink
Merge pull request #689 from oclif/mdonnalley/eslint-9
Browse files Browse the repository at this point in the history
chore(W-17692101): eslint 9
  • Loading branch information
mdonnalley authored Jan 30, 2025
2 parents c367bee + 0e91138 commit e760461
Show file tree
Hide file tree
Showing 7 changed files with 588 additions and 306 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

7 changes: 0 additions & 7 deletions .eslintrc.json

This file was deleted.

31 changes: 31 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {includeIgnoreFile} from '@eslint/compat'
import oclif from 'eslint-config-oclif'
import prettier from 'eslint-config-prettier'
import path from 'node:path'
import {fileURLToPath} from 'node:url'

const gitignorePath = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '.gitignore')

export default [
includeIgnoreFile(gitignorePath),
...oclif,
prettier,
{
languageOptions: {
globals: {
BufferEncoding: 'readonly',
},
},
rules: {'jsdoc/no-undefined-types': 'off', 'unicorn/import-style': 1, 'unicorn/prefer-node-protocol': 0},
},
{
files: ['test/fixtures/**/*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'n/no-extraneous-require': 'off',
'unicorn/no-anonymous-default-export': 'off',
'unicorn/prefer-module': 'off',
},
},
]
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"devDependencies": {
"@commitlint/config-conventional": "^18.6.3",
"@eslint/compat": "^1.2.5",
"@oclif/core": "^4.2.4",
"@oclif/prettier-config": "^0.2.1",
"@types/chai": "^5.0.1",
Expand All @@ -21,10 +22,9 @@
"@types/node": "^18",
"chai": "^5.1.2",
"commitlint": "^18.6.1",
"eslint": "^8.57.1",
"eslint-config-oclif": "^5.2.2",
"eslint-config-oclif-typescript": "^3.1.13",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.19.0",
"eslint-config-oclif": "^6.0.0",
"eslint-config-prettier": "^10.0.1",
"husky": "^9.1.7",
"lint-staged": "^15.4.2",
"mocha": "^10",
Expand All @@ -48,7 +48,7 @@
"repository": "oclif/test",
"scripts": {
"build": "shx rm -rf lib && tsc",
"lint": "eslint . --ext .ts",
"lint": "eslint",
"posttest": "yarn lint",
"prepare": "husky && yarn build",
"prepublishOnly": "yarn run build",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ export async function captureOutput<T>(fn: () => Promise<unknown>, opts?: Captur
stdout: process.stdout.write,
}

const output: Record<'stderr' | 'stdout', Array<Uint8Array | string>> = {
const output: Record<'stderr' | 'stdout', Array<string | Uint8Array>> = {
stderr: [],
stdout: [],
}

const toString = (str: Uint8Array | string): string => (stripAnsi ? ansis.strip(str.toString()) : str.toString())
const toString = (str: string | Uint8Array): string => (stripAnsi ? ansis.strip(str.toString()) : str.toString())
const getStderr = (): string => output.stderr.map((b) => toString(b)).join('')
const getStdout = (): string => output.stdout.map((b) => toString(b)).join('')

const mock =
(std: 'stderr' | 'stdout'): MockedStderr | MockedStdout =>
(str: Uint8Array | string, encoding?: ((err?: Error) => void) | BufferEncoding, cb?: (err?: Error) => void) => {
(str: string | Uint8Array, encoding?: ((err?: Error) => void) | BufferEncoding, cb?: (err?: Error) => void) => {
output[std].push(str)

if (print) {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/multi/src/commands/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {Command, Flags} = require('@oclif/core')
class CLI extends Command {
async run() {
const {flags} = await this.parse(CLI)
const code = parseInt(flags.code || '1')
const code = Number.parseInt(flags.code || '1', 10)
this.log(`exiting with code ${code}`)
this.exit(code)
}
Expand Down
Loading

0 comments on commit e760461

Please # to comment.