@@ -2,7 +2,6 @@ import * as NodeContext from "@effect/platform-node/NodeContext";
22import * as NodeRuntime from "@effect/platform-node/NodeRuntime" ;
33import * as FileSystem from "@effect/platform/FileSystem" ;
44import * as Path from "@effect/platform/Path" ;
5- import pluginMod from "@eslint-react/eslint-plugin" ;
65import ansis from "ansis" ;
76import { identity } from "effect" ;
87import * as Effect from "effect/Effect" ;
@@ -103,72 +102,73 @@ function generateRuleMetaJson(metas: RuleMeta[]) {
103102 } ) ;
104103}
105104
105+ // TODO: Not implemented yet
106106// Process the rules overview file
107- const processRulesOverview = Effect . gen ( function * ( ) {
108- const fs = yield * FileSystem . FileSystem ;
109- const path = yield * Path . Path ;
110- const targetPath = path . join ( "apps" , "website" , "content" , "docs" , "rules" , "overview.mdx" ) ;
111- const markdownTables = [ [ "" ] , [ "" ] , [ "" ] , [ "" ] , [ "" ] , [ "" ] ] ;
112- for ( const doc of glob ( DOCS_GLOB ) ) {
113- const catename = / ^ p a c k a g e s \/ p l u g i n s \/ e s l i n t - p l u g i n - r e a c t - ( [ ^ / ] + ) / u. exec ( doc ) ?. [ 1 ] ?? "" ;
114- const basename = path . parse ( path . basename ( doc ) ) . name ;
115- const filename = path . resolve ( doc ) . replace ( / \. m d x $ / u, ".ts" ) ;
116- const rulename = `${ catename } /${ basename } ` ;
117- const tableIndex = orderedCategories . findIndex ( ( c ) => c . key === catename ) ;
118- const tableLines = markdownTables [ tableIndex ] ?? [ ] ;
119- const { default : ruleModule , RULE_FEATURES , RULE_NAME } = yield * Effect . tryPromise ( ( ) => import ( filename ) ) ;
120- const description = match ( ruleModule )
121- . with ( { meta : { docs : { description : P . select ( P . string ) } } } , identity )
122- . otherwise ( ( ) => "No description available." ) ;
123- const isPluginX = catename === "x" ;
124- const entryInRecommended = pluginMod
125- . configs
126- . recommended
127- . rules
128- ?. [ isPluginX ? `@eslint-react/ ${ RULE_NAME } ` : `@eslint-react/ ${ catename } / ${ RULE_NAME } ` ] ;
129- const entryInStrict = pluginMod
130- . configs
131- . strict
132- . rules
133- ?. [ isPluginX ? `@eslint-react/ ${ RULE_NAME } ` : `@eslint-react/ ${ catename } / ${ RULE_NAME } ` ] ;
134- const getSeverity = ( entry : unknown ) : number =>
135- match ( entry )
136- . with ( "off" , ( ) => 0 )
137- . with ( "warn " , ( ) => 1 )
138- . with ( "error " , ( ) => 2 )
139- . with ( P . number , ( n ) => n )
140- . with ( P . array ( ) , ( [ s ] ) => getSeverity ( s ) )
141- . otherwise ( ( ) => 0 ) ;
142- const getSeverityIcon = ( severity : number ) => {
143- return match ( severity )
144- . with ( 0 , ( ) => "0️⃣" )
145- . with ( 1 , ( ) => "1️⃣ " )
146- . with ( 2 , ( ) => "2️⃣ " )
147- . otherwise ( ( ) => "0️⃣" ) ;
148- } ;
149- const getFeatureIcon = ( feature : unknown ) => {
150- return match ( feature )
151- . with ( "CFG" , ( ) => "⚙️" )
152- . with ( "DBG " , ( ) => "🐞 " )
153- . with ( "FIX " , ( ) => "🔧 " )
154- . with ( "MOD " , ( ) => "🔄 " )
155- . with ( "TSC " , ( ) => "💭 " )
156- . with ( "EXP " , ( ) => "🧪 " )
157- . otherwise ( ( ) => "" ) ;
158- } ;
159- const severityInRecommended = getSeverity ( entryInRecommended ) ;
160- const severityInStrict = getSeverity ( entryInStrict ) ;
161- tableLines . push (
162- [
163- `[ ${ basename } ]( ${ catename === "x" ? "" : catename + "-" } ${ basename } )` ,
164- ` ${ getSeverity ( entryInRecommended ) } ${ getSeverity ( entryInStrict ) } `,
165- `${ RULE_FEATURES . map ( ( f : string ) => "`" + getFeatureIcon ( f ) + "`" ) . join ( " " ) } ` ,
166- ] . join ( " | " ) ,
167- ) ;
168- // yield* Effect.log(markdownTables );
169- // TODO: Not implemented yet.
170- }
171- } ) ;
107+ // const processRulesOverview = Effect.gen(function*() {
108+ // const fs = yield* FileSystem.FileSystem;
109+ // const path = yield* Path.Path;
110+ // const targetPath = path.join("apps", "website", "content", "docs", "rules", "overview.mdx");
111+ // const markdownTables = [[""], [""], [""], [""], [""], [""]];
112+ // for (const doc of glob(DOCS_GLOB)) {
113+ // const catename = /^packages\/plugins\/eslint-plugin-react-([^/]+)/u.exec(doc)?.[1] ?? "";
114+ // const basename = path.parse(path.basename(doc)).name;
115+ // const filename = path.resolve(doc).replace(/\.mdx$/u, ".ts");
116+ // const rulename = `${catename}/${basename}`;
117+ // const tableIndex = orderedCategories.findIndex((c) => c.key === catename);
118+ // const tableLines = markdownTables[tableIndex] ?? [];
119+ // // TODO: Read rule module directly from pluginMod instead of dynamic import
120+ // const { default: ruleModule, RULE_FEATURES, RULE_NAME } = yield* Effect.tryPromise(() => import(filename));
121+ // const description = match(ruleModule )
122+ // .with({ meta: { docs: { description: P.select(P.string) } } }, identity)
123+ // .otherwise(() => "No description available.") ;
124+ // const isPluginX = catename === "x";
125+ // const entryInRecommended = pluginMod
126+ // .configs
127+ // .recommended
128+ // .rules
129+ // ?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
130+ // const entryInStrict = pluginMod
131+ // .configs
132+ // .strict
133+ // .rules
134+ // ?.[isPluginX ? `@eslint-react/${RULE_NAME}` : `@eslint-react/${catename}/${RULE_NAME}`];
135+ // const getSeverity = (entry: unknown): number =>
136+ // match(entry )
137+ // .with("off ", () => 0 )
138+ // .with("warn ", () => 1 )
139+ // .with("error" , () => 2 )
140+ // .with(P.number , (n ) => n )
141+ // .with(P.array(), ([s]) => getSeverity(s))
142+ // .otherwise(( ) => 0);
143+ // const getSeverityIcon = (severity: number) => {
144+ // return match(severity )
145+ // .with(0 , () => "0️⃣ ")
146+ // .with(1 , () => "1️⃣ ")
147+ // .with(2, () => "2️⃣")
148+ // .otherwise(() => "0️⃣") ;
149+ // };
150+ // const getFeatureIcon = (feature: unknown) => {
151+ // return match(feature )
152+ // .with("CFG ", () => "⚙️ ")
153+ // .with("DBG ", () => "🐞 ")
154+ // .with("FIX ", () => "🔧 ")
155+ // .with("MOD ", () => "🔄 ")
156+ // .with("TSC ", () => "💭 ")
157+ // .with("EXP", () => "🧪")
158+ // .otherwise(() => "") ;
159+ // } ;
160+ // const severityInRecommended = getSeverity(entryInRecommended );
161+ // const severityInStrict = getSeverity(entryInStrict);
162+ // tableLines.push(
163+ // [
164+ // `[${basename}](${catename === "x" ? "" : catename + "-"}${basename}) `,
165+ // `${getSeverity(entryInRecommended)} ${getSeverity(entryInStrict )}`,
166+ // `${RULE_FEATURES.map((f: string) => "`" + getFeatureIcon(f) + "`").join(" ")}` ,
167+ // ].join(" | "),
168+ // );
169+ // // yield* Effect.log(markdownTables);
170+ // }
171+ // });
172172
173173const processChangelog = Effect . gen ( function * ( ) {
174174 const fs = yield * FileSystem . FileSystem ;
@@ -206,8 +206,6 @@ const program = Effect.gen(function*() {
206206
207207 yield * generateRuleMetaJson ( metas ) ;
208208
209- yield * processRulesOverview ;
210-
211209 yield * processChangelog ;
212210
213211 yield * Effect . log ( ansis . bold . green ( "Documentation processing completed." ) ) ;
0 commit comments