Skip to content

Commit 6ac8116

Browse files
committed
feat: switch to native ESM and add exports
BREAKING CHANGE: adds exports; requires Node 18
1 parent 3677e43 commit 6ac8116

25 files changed

+303
-506
lines changed

.eslintignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ node_modules
55
.*
66
!.babelrc.json
77
!.editorconfig
8-
!.eslintignore
9-
!.eslintrc.json
108
!.gitattributes
119
!.github
1210
!.gitignore
1311
!.husky
14-
!.ncurc.js
12+
!.ncurc.cjs
1513
!.npmignore
1614
!.README
1715
!.releaserc
18-
!.vscode
16+
!.vscode

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
npm test && npm run build && npm run check-docs
4+
npm test && npm run build

.ncurc.js renamed to .ncurc.cjs

File renamed without changes.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ for more on the allowable properties (e.g., `code`, `errors` (for invalid rules)
6464
Note that besides `pnpm test` there is `pnpm test-cov`, which shows more
6565
detailed coverage information. Coverage should be maintained at 100%, and
6666
if there are a few guards in place for future use, the code block in question
67-
can be ignored by being preceded by `/* istanbul ignore next */` (including
67+
can be ignored by being preceded by `/* c8 ignore next */` (including
6868
for warnings where the block is never passed over (i.e., the block is always
6969
entered)). If you want to test without coverage at all, you can use
7070
`pnpm test-no-cov`. To only test rules rather than other files, you
Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import globals from 'globals';
2-
import jsdoc from './dist/index.js';
2+
import jsdoc from './src/index.js';
33
// import canonical from 'eslint-config-canonical';
44
// import canonicalJsdoc from 'eslint-config-canonical/jsdoc.js';
55

@@ -21,7 +21,35 @@ export default [
2121
},
2222
{
2323
...common,
24-
files: ['.ncurc.js'],
24+
languageOptions: {
25+
ecmaVersion: 'latest',
26+
sourceType: 'module',
27+
globals: globals.node
28+
},
29+
settings: {
30+
jsdoc: {
31+
mode: 'typescript'
32+
}
33+
},
34+
rules: {
35+
'array-element-newline': 0,
36+
'filenames/match-regex': 0,
37+
'import/extensions': 0,
38+
'import/no-useless-path-segments': 0,
39+
'prefer-named-capture-group': 0,
40+
'unicorn/no-array-reduce': 0,
41+
'unicorn/no-unsafe-regex': 0,
42+
'unicorn/prefer-array-some': 0,
43+
'unicorn/prevent-abbreviations': 0,
44+
'unicorn/import-index': 0,
45+
'linebreak-style': 0,
46+
'no-inline-comments': 0,
47+
'no-extra-parens': 0
48+
}
49+
},
50+
{
51+
...common,
52+
files: ['.ncurc.cjs'],
2553
languageOptions: {
2654
parserOptions: {
2755
ecmaFeatures: {
@@ -41,35 +69,13 @@ export default [
4169
{
4270
...common,
4371
files: ['test/**/*.js'],
72+
languageOptions: {
73+
ecmaVersion: 'latest',
74+
sourceType: 'module'
75+
},
4476
rules: {
4577
'no-restricted-syntax': 0,
4678
'unicorn/prevent-abbreviations': 0
4779
}
4880
},
49-
{
50-
...common,
51-
languageOptions: {
52-
globals: globals.node
53-
},
54-
settings: {
55-
jsdoc: {
56-
mode: 'typescript'
57-
}
58-
},
59-
rules: {
60-
'array-element-newline': 0,
61-
'filenames/match-regex': 0,
62-
'import/extensions': 0,
63-
'import/no-useless-path-segments': 0,
64-
'prefer-named-capture-group': 0,
65-
'unicorn/no-array-reduce': 0,
66-
'unicorn/no-unsafe-regex': 0,
67-
'unicorn/prefer-array-some': 0,
68-
'unicorn/prevent-abbreviations': 0,
69-
'unicorn/import-index': 0,
70-
'linebreak-style': 0,
71-
'no-inline-comments': 0,
72-
'no-extra-parens': 0
73-
}
74-
}
7581
];

package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"@babel/plugin-syntax-class-properties": "^7.12.13",
2525
"@babel/plugin-transform-flow-strip-types": "^7.23.3",
2626
"@babel/preset-env": "^7.23.7",
27-
"@babel/register": "^7.23.7",
2827
"@es-joy/escodegen": "^3.5.1",
2928
"@es-joy/jsdoc-eslint-parser": "^0.21.1",
3029
"@hkdobrev/run-if-changed": "^0.3.1",
@@ -42,9 +41,10 @@
4241
"@types/node": "^20.10.6",
4342
"@types/semver": "^7.5.6",
4443
"@types/spdx-expression-parse": "^3.0.5",
45-
"@typescript-eslint/parser": "^6.16.0",
44+
"@typescript-eslint/parser": "^6.17.0",
4645
"babel-plugin-add-module-exports": "^1.0.4",
4746
"babel-plugin-istanbul": "^6.1.1",
47+
"c8": "^8.0.1",
4848
"camelcase": "^6.3.0",
4949
"chai": "^4.3.10",
5050
"cross-env": "^7.0.3",
@@ -61,14 +61,14 @@
6161
"lint-staged": "^15.2.0",
6262
"lodash.defaultsdeep": "^4.6.1",
6363
"mocha": "^10.2.0",
64-
"nyc": "^15.1.0",
6564
"open-editor": "^3.0.0",
65+
"replace": "^1.2.2",
6666
"rimraf": "^5.0.5",
6767
"semantic-release": "^22.0.12",
6868
"typescript": "5.3.3"
6969
},
7070
"engines": {
71-
"node": ">=16"
71+
"node": ">=18"
7272
},
7373
"keywords": [
7474
"eslint",
@@ -83,18 +83,21 @@
8383
],
8484
"*.js": "npm run lint-arg -- --fix"
8585
},
86+
"type": "module",
8687
"main": "./dist/index.js",
8788
"types": "./dist/index.d.ts",
89+
"exports": {
90+
"types": "./dist/index.d.ts",
91+
"import": "./src/index.js",
92+
"require": "./dist/index.cjs"
93+
},
8894
"name": "eslint-plugin-jsdoc",
8995
"mocha": {
90-
"require": [
91-
"@babel/register"
92-
],
9396
"reporter": "dot",
9497
"recursive": true,
9598
"timeout": 12000
9699
},
97-
"nyc": {
100+
"c8": {
98101
"branches": 100,
99102
"check-coverage": true,
100103
"exclude": [
@@ -107,9 +110,6 @@
107110
"instrument": false,
108111
"lines": 100,
109112
"reporter": "text-summary",
110-
"require": [
111-
"@babel/register"
112-
],
113113
"sourceMap": false,
114114
"statements": 100
115115
},
@@ -126,7 +126,7 @@
126126
"scripts": {
127127
"tsc": "tsc",
128128
"tsc-build": "tsc -p tsconfig-prod.json",
129-
"build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && pnpm tsc-build",
129+
"build": "rimraf ./dist && cross-env NODE_ENV=production babel ./src --out-file-extension .cjs --out-dir ./dist --copy-files --source-maps --ignore ./src/bin/*.js --no-copy-ignored && replace 'require\\(\"\\.(.*?)\\.[^.]*?\"\\)' 'require(\".$1.cjs\")' 'dist' -r --include=\"*.cjs\" && pnpm tsc-build",
130130
"check-docs": "babel-node ./src/bin/generateDocs.js --check",
131131
"create-docs": "npm run create-options && babel-node ./src/bin/generateDocs.js",
132132
"create-rule": "babel-node ./src/bin/generateRule.js",
@@ -137,8 +137,8 @@
137137
"lint-fix": "npm run lint-arg -- --fix .",
138138
"prepare": "husky install",
139139
"test-no-cov": "cross-env BABEL_ENV=test mocha",
140-
"test": "nyc npm run test-no-cov",
141-
"test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
140+
"test": "c8 npm run test-no-cov",
141+
"test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
142142
"test-index": "npm run test-no-cov -- test/rules/index.js"
143143
},
144144
"version": "1.0.0"

0 commit comments

Comments
 (0)