Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove oxlint version from generator #206

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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