Skip to content

Commit

Permalink
tests: update tests to use updated ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
MLKendall committed Mar 20, 2024
1 parent 1c568d7 commit 26998d7
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
const assert = require('assert');
const Engine = require('eslint').CLIEngine;
const { ESLint } = require("eslint");

const cli = new Engine({
configFile: 'index.js',
const cli = new ESLint({
overrideConfigFile: 'index.js',
});

const lint = text => cli.executeOnText(text);
const lint = text => cli.lintText(text);

describe('Non-react JS', function() {
it('Will pass', function() {
const test = lint(`
const foo = 'foo';
window.location(foo);\n`);

const message = test.errorCount > 0 && test.results[0].messages[0].message;

assert.equal(test.errorCount, 0, message);
describe('Non-react JS', function () {
it('Will pass', async function () {
const test = await lint(`const foo = 'foo'; window.location(foo);\n`);
const message = test[0].errorCount > 0 && test[0].messages[0].message;
assert.equal(test[0].errorCount, 0, message);
});
});

describe('React JS', function() {
it('Will pass', function() {
const test = cli.executeOnText(`
import React, { Component } from 'react';
describe('React JS', function () {
it('Will pass', async function () {
const test = await lint(
`import React, { Component } from 'react';
export class Foo extends Component {
constructor(props) {
Expand All @@ -34,10 +30,8 @@ export class Foo extends Component {
return <p>Foo</p>;
}
}
`);

const message = test.errorCount > 0 && test.results[0].messages[0].message;

assert.equal(test.errorCount, 0, message);
` );
const message = test[0].errorCount > 0 && test[0].messages[0].message;
assert.equal(test[0].errorCount, 0, message);
});
});

0 comments on commit 26998d7

Please sign in to comment.