Skip to content

Commit

Permalink
refactor: remove oxlint version from generator (#206)
Browse files Browse the repository at this point in the history
it is only used for output. after #204 the output does not match always
the cloned version
  • Loading branch information
Sysix authored Oct 31, 2024
1 parent 005fa50 commit 123d941
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
7 changes: 1 addition & 6 deletions scripts/config-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ export enum RulesGrouping {
export type ResultMap = Map<string, string[]>;

export class ConfigGenerator {
private oxlintVersion: string;
private rulesGrouping: RulesGrouping;
private rulesArray: Rule[];
constructor(
oxlintVersion: string,
rulesArray: Rule[] = [],
rulesGrouping: RulesGrouping = RulesGrouping.SCOPE
) {
this.oxlintVersion = oxlintVersion;
this.rulesArray = rulesArray;
this.rulesGrouping = rulesGrouping;
}
Expand All @@ -46,9 +43,7 @@ export class ConfigGenerator {
}

public async generateRulesCode() {
console.log(
`Generating config for ${this.oxlintVersion}, grouped by ${this.rulesGrouping}`
);
console.log(`Generating config, grouped by ${this.rulesGrouping}`);

const rulesGrouping = this.rulesGrouping;
const rulesArray = this.rulesArray;
Expand Down
17 changes: 2 additions & 15 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { RulesGenerator, RulesGrouping } from './rules-generator.js';
import { ConfigGenerator } from './config-generator.js';
import { traverseRules } from './traverse-rules.js';
import { getLatestVersionFromClonedRepo } from './oxlint-version.js';
import { TARGET_DIRECTORY, VERSION_PREFIX } from './constants.js';

const { successResultArray, failureResultArray } = await traverseRules();

Expand All @@ -12,19 +10,8 @@ if (failureResultArray.length > 0) {
);
}

const oxlintVersion = getLatestVersionFromClonedRepo(
TARGET_DIRECTORY,
VERSION_PREFIX
);

if (!oxlintVersion) {
throw new Error(
'Failed to get the latest version of oxlint, did you forget to run `pnpm clone`?'
);
}

const rulesGenerator = new RulesGenerator(oxlintVersion, successResultArray);
const configGenerator = new ConfigGenerator(oxlintVersion, successResultArray);
const rulesGenerator = new RulesGenerator(successResultArray);
const configGenerator = new ConfigGenerator(successResultArray);

[rulesGenerator, configGenerator].forEach(async (generator) => {
generator.setRulesGrouping(RulesGrouping.SCOPE);
Expand Down
1 change: 0 additions & 1 deletion scripts/rules-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ suite('RulesGenerator', () => {

// Create an instance of RulesGenerator
const generator = new RulesGenerator(
'1.0.0',
successResultArray,
RulesGrouping.SCOPE
);
Expand Down
7 changes: 1 addition & 6 deletions scripts/rules-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ export enum RulesGrouping {
export type ResultMap = Map<string, string[]>;

export class RulesGenerator {
private oxlintVersion: string;
private rulesGrouping: RulesGrouping;
private rulesArray: Rule[];
constructor(
oxlintVersion: string,
rulesArray: Rule[] = [],
rulesGrouping: RulesGrouping = RulesGrouping.SCOPE
) {
this.oxlintVersion = oxlintVersion;
this.rulesArray = rulesArray;
this.rulesGrouping = rulesGrouping;
}
Expand All @@ -46,9 +43,7 @@ export class RulesGenerator {
}

public async generateRulesCode() {
console.log(
`Generating rules for ${this.oxlintVersion}, grouped by ${this.rulesGrouping}`
);
console.log(`Generating rules, grouped by ${this.rulesGrouping}`);

const rulesGrouping = this.rulesGrouping;
const rulesArray = this.rulesArray;
Expand Down

0 comments on commit 123d941

Please sign in to comment.