Skip to content

Commit

Permalink
feat: expose sub entries for each rule
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Nov 11, 2023
1 parent 47348a9 commit 74748cb
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 3 deletions.
69 changes: 68 additions & 1 deletion packages/eslint-plugin-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,74 @@
},
"./rule-options": {
"types": "./dts/rule-options.d.ts"
}
},
"./rules/array-bracket-newline": "./dist/array-bracket-newline.js",
"./rules/array-bracket-spacing": "./dist/array-bracket-spacing.js",
"./rules/array-element-newline": "./dist/array-element-newline.js",
"./rules/arrow-parens": "./dist/arrow-parens.js",
"./rules/arrow-spacing": "./dist/arrow-spacing.js",
"./rules/block-spacing": "./dist/block-spacing.js",
"./rules/brace-style": "./dist/brace-style.js",
"./rules/comma-dangle": "./dist/comma-dangle.js",
"./rules/comma-spacing": "./dist/comma-spacing.js",
"./rules/comma-style": "./dist/comma-style.js",
"./rules/computed-property-spacing": "./dist/computed-property-spacing.js",
"./rules/dot-location": "./dist/dot-location.js",
"./rules/eol-last": "./dist/eol-last.js",
"./rules/func-call-spacing": "./dist/func-call-spacing.js",
"./rules/function-call-argument-newline": "./dist/function-call-argument-newline.js",
"./rules/function-paren-newline": "./dist/function-paren-newline.js",
"./rules/generator-star-spacing": "./dist/generator-star-spacing.js",
"./rules/implicit-arrow-linebreak": "./dist/implicit-arrow-linebreak.js",
"./rules/indent": "./dist/indent.js",
"./rules/jsx-quotes": "./dist/jsx-quotes.js",
"./rules/key-spacing": "./dist/key-spacing.js",
"./rules/keyword-spacing": "./dist/keyword-spacing.js",
"./rules/linebreak-style": "./dist/linebreak-style.js",
"./rules/lines-around-comment": "./dist/lines-around-comment.js",
"./rules/lines-between-class-members": "./dist/lines-between-class-members.js",
"./rules/max-len": "./dist/max-len.js",
"./rules/max-statements-per-line": "./dist/max-statements-per-line.js",
"./rules/multiline-ternary": "./dist/multiline-ternary.js",
"./rules/new-parens": "./dist/new-parens.js",
"./rules/newline-per-chained-call": "./dist/newline-per-chained-call.js",
"./rules/no-confusing-arrow": "./dist/no-confusing-arrow.js",
"./rules/no-extra-parens": "./dist/no-extra-parens.js",
"./rules/no-extra-semi": "./dist/no-extra-semi.js",
"./rules/no-floating-decimal": "./dist/no-floating-decimal.js",
"./rules/no-mixed-operators": "./dist/no-mixed-operators.js",
"./rules/no-mixed-spaces-and-tabs": "./dist/no-mixed-spaces-and-tabs.js",
"./rules/no-multi-spaces": "./dist/no-multi-spaces.js",
"./rules/no-multiple-empty-lines": "./dist/no-multiple-empty-lines.js",
"./rules/no-tabs": "./dist/no-tabs.js",
"./rules/no-trailing-spaces": "./dist/no-trailing-spaces.js",
"./rules/no-whitespace-before-property": "./dist/no-whitespace-before-property.js",
"./rules/nonblock-statement-body-position": "./dist/nonblock-statement-body-position.js",
"./rules/object-curly-newline": "./dist/object-curly-newline.js",
"./rules/object-curly-spacing": "./dist/object-curly-spacing.js",
"./rules/object-property-newline": "./dist/object-property-newline.js",
"./rules/one-var-declaration-per-line": "./dist/one-var-declaration-per-line.js",
"./rules/operator-linebreak": "./dist/operator-linebreak.js",
"./rules/padded-blocks": "./dist/padded-blocks.js",
"./rules/padding-line-between-statements": "./dist/padding-line-between-statements.js",
"./rules/quote-props": "./dist/quote-props.js",
"./rules/quotes": "./dist/quotes.js",
"./rules/rest-spread-spacing": "./dist/rest-spread-spacing.js",
"./rules/semi": "./dist/semi.js",
"./rules/semi-spacing": "./dist/semi-spacing.js",
"./rules/semi-style": "./dist/semi-style.js",
"./rules/space-before-blocks": "./dist/space-before-blocks.js",
"./rules/space-before-function-paren": "./dist/space-before-function-paren.js",
"./rules/space-in-parens": "./dist/space-in-parens.js",
"./rules/space-infix-ops": "./dist/space-infix-ops.js",
"./rules/space-unary-ops": "./dist/space-unary-ops.js",
"./rules/spaced-comment": "./dist/spaced-comment.js",
"./rules/switch-colon-spacing": "./dist/switch-colon-spacing.js",
"./rules/template-curly-spacing": "./dist/template-curly-spacing.js",
"./rules/template-tag-spacing": "./dist/template-tag-spacing.js",
"./rules/wrap-iife": "./dist/wrap-iife.js",
"./rules/wrap-regex": "./dist/wrap-regex.js",
"./rules/yield-star-spacing": "./dist/yield-star-spacing.js"
},
"main": "./dist/index.js",
"types": "./dts/index.d.ts",
Expand Down
20 changes: 19 additions & 1 deletion packages/eslint-plugin-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,25 @@
},
"./rule-options": {
"types": "./dts/rule-options.d.ts"
}
},
"./rules/jsx-child-element-spacing": "./dist/jsx-child-element-spacing.js",
"./rules/jsx-closing-bracket-location": "./dist/jsx-closing-bracket-location.js",
"./rules/jsx-closing-tag-location": "./dist/jsx-closing-tag-location.js",
"./rules/jsx-curly-brace-presence": "./dist/jsx-curly-brace-presence.js",
"./rules/jsx-curly-newline": "./dist/jsx-curly-newline.js",
"./rules/jsx-curly-spacing": "./dist/jsx-curly-spacing.js",
"./rules/jsx-equals-spacing": "./dist/jsx-equals-spacing.js",
"./rules/jsx-first-prop-new-line": "./dist/jsx-first-prop-new-line.js",
"./rules/jsx-indent": "./dist/jsx-indent.js",
"./rules/jsx-indent-props": "./dist/jsx-indent-props.js",
"./rules/jsx-max-props-per-line": "./dist/jsx-max-props-per-line.js",
"./rules/jsx-newline": "./dist/jsx-newline.js",
"./rules/jsx-one-expression-per-line": "./dist/jsx-one-expression-per-line.js",
"./rules/jsx-props-no-multi-spaces": "./dist/jsx-props-no-multi-spaces.js",
"./rules/jsx-self-closing-comp": "./dist/jsx-self-closing-comp.js",
"./rules/jsx-sort-props": "./dist/jsx-sort-props.js",
"./rules/jsx-tag-spacing": "./dist/jsx-tag-spacing.js",
"./rules/jsx-wrap-multilines": "./dist/jsx-wrap-multilines.js"
},
"main": "./dist/index.js",
"types": "./dts/index.d.ts",
Expand Down
23 changes: 22 additions & 1 deletion packages/eslint-plugin-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,28 @@
},
"./rule-options": {
"types": "./dts/rule-options.d.ts"
}
},
"./rules/block-spacing": "./dist/block-spacing.js",
"./rules/brace-style": "./dist/brace-style.js",
"./rules/comma-dangle": "./dist/comma-dangle.js",
"./rules/comma-spacing": "./dist/comma-spacing.js",
"./rules/func-call-spacing": "./dist/func-call-spacing.js",
"./rules/indent": "./dist/indent.js",
"./rules/key-spacing": "./dist/key-spacing.js",
"./rules/keyword-spacing": "./dist/keyword-spacing.js",
"./rules/lines-around-comment": "./dist/lines-around-comment.js",
"./rules/lines-between-class-members": "./dist/lines-between-class-members.js",
"./rules/member-delimiter-style": "./dist/member-delimiter-style.js",
"./rules/no-extra-parens": "./dist/no-extra-parens.js",
"./rules/no-extra-semi": "./dist/no-extra-semi.js",
"./rules/object-curly-spacing": "./dist/object-curly-spacing.js",
"./rules/padding-line-between-statements": "./dist/padding-line-between-statements.js",
"./rules/quotes": "./dist/quotes.js",
"./rules/semi": "./dist/semi.js",
"./rules/space-before-blocks": "./dist/space-before-blocks.js",
"./rules/space-before-function-paren": "./dist/space-before-function-paren.js",
"./rules/space-infix-ops": "./dist/space-infix-ops.js",
"./rules/type-annotation-spacing": "./dist/type-annotation-spacing.js"
},
"main": "./dist/index.js",
"types": "./dts/index.d.ts",
Expand Down
26 changes: 26 additions & 0 deletions scripts/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function run() {
await writeRulesIndex(pkg)
await writeREADME(pkg)
await writePackageDTS(pkg)
await updateExports(pkg)
packages.push(pkg)
}

Expand Down Expand Up @@ -175,6 +176,7 @@ async function writePackageDTS(pkg: PackageInfo) {
]
}),
'}',
'',
]

await fs.writeFile(
Expand All @@ -197,6 +199,30 @@ export {}
)
}

async function updateExports(pkg: PackageInfo) {
if (!pkg.rules.length)
return

const pkgJson = JSON.parse(await fs.readFile(join(pkg.path, 'package.json'), 'utf-8'))
pkgJson.exports = {
'.': {
types: './dts/index.d.ts',
require: './dist/index.js',
default: './dist/index.js',
},
'./define-config-support': {
types: './dts/define-config-support.d.ts',
},
'./rule-options': {
types: './dts/rule-options.d.ts',
},
...Object.fromEntries(
pkg.rules.map(i => [`./rules/${i.name}`, `./dist/${i.name}.js`]),
),
}
await fs.writeFile(join(pkg.path, 'package.json'), `${JSON.stringify(pkgJson, null, 2)}\n`, 'utf-8')
}

async function writeREADME(pkg: PackageInfo) {
if (!pkg.rules.length)
return
Expand Down

0 comments on commit 74748cb

Please sign in to comment.