Skip to content

Commit 55edfb9

Browse files
authored
fix!: remove rollup, extraneous types and migrate to ESM-only (#197)
* fix!: remove `rollup`, extraneous types and migrate to ESM-only * wip * wip * wip: arethetypeswrong * wip: convention
1 parent 774dd3e commit 55edfb9

File tree

15 files changed

+35
-176
lines changed

15 files changed

+35
-176
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ jobs:
5656
run: npm install
5757
- name: Check Types
5858
run: npm run test:types
59+
are_the_types_wrong:
60+
name: Are the types wrong?
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v6
64+
- name: Setup Node.js
65+
uses: actions/setup-node@v6
66+
with:
67+
node-version: "lts/*"
68+
- name: Install Packages
69+
run: npm install
70+
- name: Check validity of type definitions
71+
run: npm run lint:types
5972
jsr_test:
6073
name: Verify JSR Publish
6174
runs-on: ubuntu-latest

jsr.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
{
22
"name": "@eslint/json",
33
"version": "0.14.0",
4-
"exports": "./dist/esm/index.js",
4+
"exports": "./dist/index.js",
55
"publish": {
66
"include": [
7-
"dist/esm/index.js",
8-
"dist/esm/index.d.ts",
9-
"dist/esm/types.ts",
7+
"dist",
108
"README.md",
119
"jsr.json",
1210
"LICENSE"

package.json

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,15 @@
44
"description": "JSON linting plugin for ESLint",
55
"author": "Nicholas C. Zakas",
66
"type": "module",
7-
"main": "dist/esm/index.js",
8-
"types": "dist/esm/index.d.ts",
7+
"main": "dist/index.js",
8+
"types": "dist/index.d.ts",
99
"exports": {
1010
".": {
11-
"require": {
12-
"types": "./dist/cjs/index.d.cts",
13-
"default": "./dist/cjs/index.cjs"
14-
},
15-
"import": {
16-
"types": "./dist/esm/index.d.ts",
17-
"default": "./dist/esm/index.js"
18-
}
11+
"types": "./dist/index.d.ts",
12+
"default": "./dist/index.js"
1913
},
2014
"./types": {
21-
"require": {
22-
"types": "./dist/cjs/types.cts"
23-
},
24-
"import": {
25-
"types": "./dist/esm/types.d.ts"
26-
}
15+
"types": "./dist/types.d.ts"
2716
}
2817
},
2918
"files": [
@@ -41,10 +30,7 @@
4130
"prettier --write"
4231
],
4332
"!(*.js)": "prettier --write --ignore-unknown",
44-
"README.md": [
45-
"npm run build:update-rules-docs"
46-
],
47-
"{src/rules/*.js,tools/update-rules-docs.js}": [
33+
"{src/rules/*.js,tools/update-rules-docs.js,README.md}": [
4834
"npm run build:update-rules-docs",
4935
"git add README.md"
5036
]
@@ -58,20 +44,20 @@
5844
},
5945
"homepage": "https://github.com/eslint/json#readme",
6046
"scripts": {
61-
"build:dedupe-types": "node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
62-
"build:cts": "node tools/build-cts.js",
47+
"build": "npm run build:rules && npm run build:types && npm run build:update-rules-docs",
6348
"build:rules": "node tools/build-rules.js",
64-
"build": "npm run build:rules && rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
49+
"build:types": "tsc",
6550
"build:update-rules-docs": "node tools/update-rules-docs.js",
6651
"prepare": "npm run build",
6752
"pretest": "npm run build",
6853
"lint": "eslint",
6954
"lint:fix": "eslint --fix",
55+
"lint:types": "attw --pack --profile esm-only",
7056
"fmt": "prettier --write .",
7157
"fmt:check": "prettier --check .",
7258
"test": "mocha \"tests/**/*.test.js\"",
7359
"test:coverage": "c8 npm test",
74-
"test:jsr": "npx jsr@latest publish --dry-run",
60+
"test:jsr": "npx -y jsr@latest publish --dry-run",
7561
"test:types": "tsc -p tests/types/tsconfig.json"
7662
},
7763
"keywords": [
@@ -89,6 +75,7 @@
8975
"natural-compare": "^1.4.0"
9076
},
9177
"devDependencies": {
78+
"@arethetypeswrong/cli": "^0.18.2",
9279
"c8": "^10.1.3",
9380
"dedent": "^1.5.3",
9481
"eslint": "^9.39.2",
@@ -99,9 +86,6 @@
9986
"mdast-util-from-markdown": "^2.0.2",
10087
"mocha": "^11.3.0",
10188
"prettier": "^3.4.1",
102-
"rollup": "^4.52.3",
103-
"rollup-plugin-copy": "^3.5.0",
104-
"rollup-plugin-delete": "^3.0.1",
10589
"typescript": "^5.9.2",
10690
"yorkie": "^2.0.0"
10791
},

rollup.config.js

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

src/languages/json-source-code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
/**
2323
* @import { DocumentNode, AnyNode, Token, LocationRange } from "@humanwhocodes/momoa";
2424
* @import { FileProblem, DirectiveType, RulesConfig } from "@eslint/core";
25-
* @import { JSONSyntaxElement } from "../types.ts";
25+
* @import { JSONSyntaxElement } from "../types.js";
2626
* @import { JSONLanguageOptions } from "./json-language.js";
2727
*/
2828

src/rules/no-duplicate-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getKey, getRawKey } from "../util.js";
1515

1616
/**
1717
* @import { MemberNode } from "@humanwhocodes/momoa";
18-
* @import { JSONRuleDefinition } from "../types.ts";
18+
* @import { JSONRuleDefinition } from "../types.js";
1919
* @typedef {"duplicateKey"} NoDuplicateKeysMessageIds
2020
* @typedef {JSONRuleDefinition<{ MessageIds: NoDuplicateKeysMessageIds }>} NoDuplicateKeysRuleDefinition
2121
*/

src/rules/no-empty-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getKey } from "../util.js";
1414
//-----------------------------------------------------------------------------
1515

1616
/**
17-
* @import { JSONRuleDefinition } from "../types.ts";
17+
* @import { JSONRuleDefinition } from "../types.js";
1818
* @typedef {"emptyKey"} NoEmptyKeysMessageIds
1919
* @typedef {JSONRuleDefinition<{ MessageIds: NoEmptyKeysMessageIds }>} NoEmptyKeysRuleDefinition
2020
*/

src/rules/no-unnormalized-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getKey } from "../util.js";
1414
//-----------------------------------------------------------------------------
1515

1616
/**
17-
* @import { JSONRuleDefinition } from "../types.ts";
17+
* @import { JSONRuleDefinition } from "../types.js";
1818
* @typedef {"unnormalizedKey"} NoUnnormalizedKeysMessageIds
1919
* @typedef {{ form: string }} NoUnnormalizedKeysOptions
2020
* @typedef {JSONRuleDefinition<{ RuleOptions: [NoUnnormalizedKeysOptions], MessageIds: NoUnnormalizedKeysMessageIds }>} NoUnnormalizedKeysRuleDefinition

src/rules/no-unsafe-values.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//-----------------------------------------------------------------------------
99

1010
/**
11-
* @import { JSONRuleDefinition } from "../types.ts";
11+
* @import { JSONRuleDefinition } from "../types.js";
1212
* @typedef {"unsafeNumber"|"unsafeInteger"|"unsafeZero"|"subnormal"|"loneSurrogate"} NoUnsafeValuesMessageIds
1313
* @typedef {JSONRuleDefinition<{ MessageIds: NoUnsafeValuesMessageIds }>} NoUnsafeValuesRuleDefinition
1414
*/

src/rules/sort-keys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { getKey, getRawKey } from "../util.js";
1616
//-----------------------------------------------------------------------------
1717

1818
/**
19-
* @import { JSONRuleDefinition } from "../types.ts";
19+
* @import { JSONRuleDefinition } from "../types.js";
2020
* @import { MemberNode } from "@humanwhocodes/momoa";
2121
* @typedef {Object} SortOptions
2222
* @property {boolean} caseSensitive Whether key comparisons are case-sensitive.

0 commit comments

Comments
 (0)