File tree Expand file tree Collapse file tree 3 files changed +69
-20
lines changed
packages/stencil-library/eslint-plugin/src Expand file tree Collapse file tree 3 files changed +69
-20
lines changed Original file line number Diff line number Diff line change 1+ import type { Linter } from "eslint" ;
2+ import type { FlatConfig } from "@typescript-eslint/utils/ts-eslint" ;
3+ import { rules } from "../rules" ;
4+
5+ // 🔁 Dynamically generate rule names with prefix
6+ const pluginName = "dnn-elements" ;
7+
8+ const prefixedRules : Linter . RulesRecord = Object . fromEntries (
9+ Object . keys ( rules ) . map ( ruleName => [
10+ `${ pluginName } /${ ruleName } ` ,
11+ "error" as const ,
12+ ] )
13+ ) ;
14+
15+ // ✅ Classic config (extends-based)
16+ export const recommended : Linter . Config = {
17+ plugins : [ pluginName ] ,
18+ rules : prefixedRules ,
19+ } ;
20+
21+ // ✅ Flat config (for modern eslint.config.js)
22+ export const flatRecommended : FlatConfig . Config [ ] = [
23+ {
24+ plugins : {
25+ [ pluginName ] : {
26+ rules,
27+ } ,
28+ } ,
29+ rules : prefixedRules ,
30+ } ,
31+ ] ;
Original file line number Diff line number Diff line change 11import { rules } from "./rules" ;
2+ import { recommended , flatRecommended } from "./configs/recommended" ;
3+ import type { Plugin } from "./types/plugin" ;
4+ const { name, version } = require ( "../../package.json" ) as {
5+ name : string ;
6+ version : string ;
7+ } ;
28
3- const { name, version } =
4- // `import`ing here would bypass the TSConfig's `"rootDir": "src"`
5- // eslint-disable-next-line @typescript-eslint/no-require-imports
6- require ( "../../package.json" ) as typeof import ( "../../package.json" ) ;
7-
8- const plugin = {
9- configs : {
10- get recommended ( ) {
11- return recommended ;
12- } ,
13- } ,
14- meta : { name, version } ,
15- rules,
16- } ;
17-
18- const recommended = {
19- plugins : {
20- "dnn-elements" : plugin ,
9+ const plugin : Plugin = {
10+ meta : { name, version } ,
11+ rules,
12+ configs : {
13+ recommended,
14+ flat : {
15+ recommended : flatRecommended ,
2116 } ,
22- rules ,
17+ } ,
2318} ;
2419
25- export default plugin ;
20+ export default plugin ;
Original file line number Diff line number Diff line change 1+ import type { Linter } from "eslint" ;
2+ import type { RuleModule } from "@typescript-eslint/utils/ts-eslint" ;
3+ import type { FlatConfig } from "@typescript-eslint/utils/ts-eslint" ;
4+
5+ type RulesRecord = Record < string , RuleModule < string , readonly unknown [ ] > > ;
6+
7+ type FlatConfigs = {
8+ flat ?: {
9+ recommended ?: FlatConfig . Config [ ] ;
10+ [ key : string ] : FlatConfig . Config [ ] | undefined ;
11+ } ;
12+ } ;
13+
14+ export type Plugin = {
15+ meta ?: {
16+ name : string ;
17+ version : string ;
18+ } ;
19+ rules : RulesRecord ;
20+ configs ?: {
21+ recommended ?: Linter . Config ;
22+ } & FlatConfigs ;
23+ } ;
You can’t perform that action at this time.
0 commit comments