Skip to content

Commit

Permalink
feat: add buildFromOxlintConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix committed Oct 27, 2024
1 parent b53ab00 commit 33a1e3e
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions src/build-from-oxlint-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,44 @@ import {
import fs from 'node:fs';

describe('buildFromOxlintConfig', () => {
it('detect active rules inside "rules" scope', () => {
['error', ['error'], 'warn', ['warn'], 1, [1], 2, [2]].forEach(
(ruleSetting) => {
describe('rules values', () => {
it('detect active rules inside "rules" scope', () => {
['error', ['error'], 'warn', ['warn'], 1, [1], 2, [2]].forEach(
(ruleSetting) => {
const rules = buildFromOxlintConfig({
rules: {
eqeqeq: ruleSetting,
},
});

expect('eqeqeq' in rules).toBe(true);
expect(rules.eqeqeq).toBe('off');
}
);
});

it('skip deactive rules inside "rules" scope', () => {
['off', ['off'], 0, [0]].forEach((ruleSetting) => {
const rules = buildFromOxlintConfig({
plugins: [],
rules: {
eqeqeq: ruleSetting,
},
});

expect('eqeqeq' in rules).toBe(true);
expect(rules.eqeqeq).toBe('off');
}
);
});

it('skip deactive rules inside "rules" scope', () => {
['off', ['off'], 0, [0]].forEach((ruleSetting) => {
const rules = buildFromOxlintConfig({
plugins: [],
rules: {
eqeqeq: ruleSetting,
},
expect('eqeqeq' in rules).toBe(false);
});

expect('eqeqeq' in rules).toBe(false);
});
});

it('skip invalid rules inside "rules" scope', () => {
['on', ['on'], 3, [3]].forEach((ruleSetting) => {
const rules = buildFromOxlintConfig({
plugins: [],
rules: {
eqeqeq: ruleSetting,
},
});
it('skip invalid rules inside "rules" scope', () => {
['on', ['on'], 3, [3]].forEach((ruleSetting) => {
const rules = buildFromOxlintConfig({
rules: {
eqeqeq: ruleSetting,
},
});

expect('eqeqeq' in rules).toBe(false);
expect('eqeqeq' in rules).toBe(false);
});
});
});

Expand Down

0 comments on commit 33a1e3e

Please sign in to comment.