Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
21 changes: 0 additions & 21 deletions .eslintrc

This file was deleted.

24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "./node_modules/gts/",
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/no-empty-object-type": "off"
}
}
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"babelrc": false,
"configFile": false,
"presets": ["@babel/preset-typescript"]
}
}
}
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12, 14, 16]
node: [20, 22, 23]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24 is out right, perhaps drop 23 in favour of 24?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, done

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
Expand All @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 22
- run: npm install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
Expand All @@ -39,7 +39,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 22
- run: npm install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 22
- run: npm install
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
Expand All @@ -70,7 +70,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 22
- run: npm install
- run: npm run test:browser
typescript:
Expand All @@ -79,7 +79,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
node-version: 22
- run: npm install
- run: npm run test:typescript
optimize:
Expand All @@ -88,6 +88,6 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 22
- run: cd test/tscc && npm install && npx @tscc/tscc
- run: cd test/tscc && node out.js
8 changes: 4 additions & 4 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**

Check failure on line 1 in lib/index.ts

View workflow job for this annotation

GitHub Actions / optimize

The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
* CJS and ESM environments.
*
* @license
* Copyright (c) 2016, Contributors
Expand All @@ -13,12 +12,13 @@
import { camelCase, decamelize, looksLikeNumber } from './string-utils.js'
import { YargsParser } from './yargs-parser.js'
import { readFileSync } from 'fs'
import { createRequire } from 'node:module';

// See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our
// version support policy. The YARGS_MIN_NODE_VERSION is used for testing only.
const minNodeVersion = (process && process.env && process.env.YARGS_MIN_NODE_VERSION)
? Number(process.env.YARGS_MIN_NODE_VERSION)
: 12
: 20
const nodeVersion = process?.versions?.node ?? process?.version?.slice(1)
if (nodeVersion) {
const major = Number(nodeVersion.match(/^([^.]+)/)![1])
Expand All @@ -29,6 +29,8 @@

// Creates a yargs-parser instance using Node.js standard libraries:
const env = process ? process.env as { [key: string]: string } : {}
const require = createRequire ? createRequire(import.meta.url) : undefined;

const parser = new YargsParser({
cwd: process.cwd,
env: () => {
Expand All @@ -37,8 +39,6 @@
format,
normalize,
resolve,
// TODO: figure out a way to combine ESM and CJS coverage, such that
// we can exercise all the lines below:
require: (path: string) => {
if (typeof require !== 'undefined') {
return require(path)
Expand Down
36 changes: 15 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
"name": "yargs-parser",
"version": "21.1.1",
"description": "the mighty option parser used by yargs",
"main": "build/index.cjs",
"main": "build/lib/index.js",
"exports": {
".": [
{
"import": "./build/lib/index.js",
"require": "./build/index.cjs"
"import": "./build/lib/index.js"
},
"./build/index.cjs"
"./build/lib/index.js"
],
"./browser": [
"./browser.js"
Expand All @@ -20,17 +19,15 @@
"scripts": {
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'",
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'",
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs",
"test": "c8 --reporter=text --reporter=html mocha test/*.cjs",
"test:esm": "c8 --reporter=text --reporter=html mocha test/*.mjs",
"pretest": "rimraf build && tsc -p tsconfig.test.json",
"test:cjs": "c8 --reporter=text --reporter=html mocha test/*.cjs",
"test": "c8 --reporter=text --reporter=html mocha test/*.mjs",
"test:browser": "start-server-and-test 'serve ./ -p 8080' http://127.0.0.1:8080/package.json 'node ./test/browser/yargs-test.cjs'",
"pretest:typescript": "npm run pretest",
"test:typescript": "c8 mocha ./build/test/typescript/*.js",
"coverage": "c8 report --check-coverage",
"precompile": "rimraf build",
"compile": "tsc",
"postcompile": "npm run build:cjs",
"build:cjs": "rollup -c",
"prepare": "npm run compile"
},
"repository": {
Expand All @@ -54,26 +51,23 @@
"@types/chai": "^4.2.11",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.4",
"@typescript-eslint/eslint-plugin": "^3.10.1",
"@typescript-eslint/parser": "^3.10.1",
"@typescript-eslint/eslint-plugin": "^8.29.1",
"@typescript-eslint/parser": "^8.29.1",
"c8": "^7.3.0",
"chai": "^4.2.0",
"cross-env": "^7.0.2",
"eslint": "^7.0.0",
"eslint": "^8.57.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-node": "^11.0.0",
"gts": "^3.0.0",
"mocha": "^10.0.0",
"puppeteer": "^16.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.22.1",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-ts": "^3.0.2",
"gts": "^6.0.2",
"mocha": "^11.1.0",
"puppeteer": "^24.6.1",
"rimraf": "^6.0.1",
"serve": "^14.0.0",
"standardx": "^7.0.0",
"start-server-and-test": "^1.11.2",
"ts-transform-default-export": "^1.0.2",
"typescript": "^4.0.0"
"typescript": "^5.8.3"
},
"files": [
"browser.js",
Expand All @@ -82,7 +76,7 @@
"!*.d.cts"
],
"engines": {
"node": ">=12"
"node": "^20.19.0 || ^22.12.0 || >=23"
},
"standardx": {
"ignore": [
Expand Down
27 changes: 0 additions & 27 deletions rollup.config.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/string-utils.cjs → test/string-utils.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global describe, it */

const { strictEqual } = require('assert')
const { camelCase, decamelize, looksLikeNumber } = require('../build/index.cjs')
import { strictEqual } from 'assert'
import { camelCase, decamelize, looksLikeNumber } from '../build/lib/string-utils.js'

describe('string-utils', function () {
describe('camelCase', () => {
Expand Down
Loading
Loading