Skip to content

Commit

Permalink
feat: switch to native ESM and add exports
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

adds exports; requires Node 18
  • Loading branch information
brettz9 committed Jan 2, 2024
1 parent 3677e43 commit 6ac8116
Show file tree
Hide file tree
Showing 25 changed files with 303 additions and 506 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ node_modules
.*
!.babelrc.json
!.editorconfig
!.eslintignore
!.eslintrc.json
!.gitattributes
!.github
!.gitignore
!.husky
!.ncurc.js
!.ncurc.cjs
!.npmignore
!.README
!.releaserc
!.vscode
!.vscode
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test && npm run build && npm run check-docs
npm test && npm run build
File renamed without changes.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ for more on the allowable properties (e.g., `code`, `errors` (for invalid rules)
Note that besides `pnpm test` there is `pnpm test-cov`, which shows more
detailed coverage information. Coverage should be maintained at 100%, and
if there are a few guards in place for future use, the code block in question
can be ignored by being preceded by `/* istanbul ignore next */` (including
can be ignored by being preceded by `/* c8 ignore next */` (including
for warnings where the block is never passed over (i.e., the block is always
entered)). If you want to test without coverage at all, you can use
`pnpm test-no-cov`. To only test rules rather than other files, you
Expand Down
62 changes: 34 additions & 28 deletions eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globals from 'globals';
import jsdoc from './dist/index.js';
import jsdoc from './src/index.js';
// import canonical from 'eslint-config-canonical';
// import canonicalJsdoc from 'eslint-config-canonical/jsdoc.js';

Expand All @@ -21,7 +21,35 @@ export default [
},
{
...common,
files: ['.ncurc.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: globals.node
},
settings: {
jsdoc: {
mode: 'typescript'
}
},
rules: {
'array-element-newline': 0,
'filenames/match-regex': 0,
'import/extensions': 0,
'import/no-useless-path-segments': 0,
'prefer-named-capture-group': 0,
'unicorn/no-array-reduce': 0,
'unicorn/no-unsafe-regex': 0,
'unicorn/prefer-array-some': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/import-index': 0,
'linebreak-style': 0,
'no-inline-comments': 0,
'no-extra-parens': 0
}
},
{
...common,
files: ['.ncurc.cjs'],
languageOptions: {
parserOptions: {
ecmaFeatures: {
Expand All @@ -41,35 +69,13 @@ export default [
{
...common,
files: ['test/**/*.js'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'no-restricted-syntax': 0,
'unicorn/prevent-abbreviations': 0
}
},
{
...common,
languageOptions: {
globals: globals.node
},
settings: {
jsdoc: {
mode: 'typescript'
}
},
rules: {
'array-element-newline': 0,
'filenames/match-regex': 0,
'import/extensions': 0,
'import/no-useless-path-segments': 0,
'prefer-named-capture-group': 0,
'unicorn/no-array-reduce': 0,
'unicorn/no-unsafe-regex': 0,
'unicorn/prefer-array-some': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/import-index': 0,
'linebreak-style': 0,
'no-inline-comments': 0,
'no-extra-parens': 0
}
}
];
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@babel/plugin-syntax-class-properties": "^7.12.13",
"@babel/plugin-transform-flow-strip-types": "^7.23.3",
"@babel/preset-env": "^7.23.7",
"@babel/register": "^7.23.7",
"@es-joy/escodegen": "^3.5.1",
"@es-joy/jsdoc-eslint-parser": "^0.21.1",
"@hkdobrev/run-if-changed": "^0.3.1",
Expand All @@ -42,9 +41,10 @@
"@types/node": "^20.10.6",
"@types/semver": "^7.5.6",
"@types/spdx-expression-parse": "^3.0.5",
"@typescript-eslint/parser": "^6.16.0",
"@typescript-eslint/parser": "^6.17.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^6.1.1",
"c8": "^8.0.1",
"camelcase": "^6.3.0",
"chai": "^4.3.10",
"cross-env": "^7.0.3",
Expand All @@ -61,14 +61,14 @@
"lint-staged": "^15.2.0",
"lodash.defaultsdeep": "^4.6.1",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"open-editor": "^3.0.0",
"replace": "^1.2.2",
"rimraf": "^5.0.5",
"semantic-release": "^22.0.12",
"typescript": "5.3.3"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"keywords": [
"eslint",
Expand All @@ -83,18 +83,21 @@
],
"*.js": "npm run lint-arg -- --fix"
},
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
"types": "./dist/index.d.ts",
"import": "./src/index.js",
"require": "./dist/index.cjs"
},
"name": "eslint-plugin-jsdoc",
"mocha": {
"require": [
"@babel/register"
],
"reporter": "dot",
"recursive": true,
"timeout": 12000
},
"nyc": {
"c8": {
"branches": 100,
"check-coverage": true,
"exclude": [
Expand All @@ -107,9 +110,6 @@
"instrument": false,
"lines": 100,
"reporter": "text-summary",
"require": [
"@babel/register"
],
"sourceMap": false,
"statements": 100
},
Expand All @@ -126,7 +126,7 @@
"scripts": {
"tsc": "tsc",
"tsc-build": "tsc -p tsconfig-prod.json",
"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",
"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",
"check-docs": "babel-node ./src/bin/generateDocs.js --check",
"create-docs": "npm run create-options && babel-node ./src/bin/generateDocs.js",
"create-rule": "babel-node ./src/bin/generateRule.js",
Expand All @@ -137,8 +137,8 @@
"lint-fix": "npm run lint-arg -- --fix .",
"prepare": "husky install",
"test-no-cov": "cross-env BABEL_ENV=test mocha",
"test": "nyc npm run test-no-cov",
"test-cov": "cross-env TIMING=1 nyc --reporter text npm run test-no-cov",
"test": "c8 npm run test-no-cov",
"test-cov": "cross-env TIMING=1 c8 --reporter text npm run test-no-cov",
"test-index": "npm run test-no-cov -- test/rules/index.js"
},
"version": "1.0.0"
Expand Down
Loading

0 comments on commit 6ac8116

Please sign in to comment.