Skip to content

Commit

Permalink
fix: format
Browse files Browse the repository at this point in the history
  • Loading branch information
Talent30 committed Nov 4, 2023
1 parent 7a9caee commit 75932be
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test.mjs
@@ -0,0 +1,35 @@
import test from 'ava';
import isPlainObj from 'is-plain-obj';
import {ESLint} from 'eslint';

const hasRule = (errors, ruleId) => errors.some(error => error.ruleId === ruleId);

async function runEslint(string, config) {
const eslint = new ESLint({
useEslintrc: false,
overrideConfig: config,
});

const [firstResult] = await eslint.lintText(string);

return firstResult.messages;
}

test('main', async t => {
const config = require('../index.js');

t.true(isPlainObj(config));
t.true(isPlainObj(config.rules));

const errors = await runEslint('\'use strict\';\nconsole.log("unicorn")\n', config);
t.true(hasRule(errors, 'quotes'), JSON.stringify(errors));
});

test('browser', async t => {
const config = require('../browser.js');

t.true(isPlainObj(config));

const errors = await runEslint('\'use strict\';\nprocess.exit();\n', config);
t.true(hasRule(errors, 'no-undef'), JSON.stringify(errors));
});

0 comments on commit 75932be

Please sign in to comment.