From 66d2a19f4a83718062d9da86159dab2070f12b2d Mon Sep 17 00:00:00 2001 From: Divlo Date: Tue, 14 Sep 2021 20:24:48 +0200 Subject: [PATCH] test: usage of ESLint class (#190) --- eslintrc.json => .eslintrc.json | 0 index.js | 2 +- package.json | 2 +- test/validate-config.js | 16 +++++----------- 4 files changed, 7 insertions(+), 13 deletions(-) rename eslintrc.json => .eslintrc.json (100%) diff --git a/eslintrc.json b/.eslintrc.json similarity index 100% rename from eslintrc.json rename to .eslintrc.json diff --git a/index.js b/index.js index 68396b3e..7a7acc7d 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,2 @@ /*! eslint-config-standard. MIT License. Feross Aboukhadijeh */ -module.exports = require('./eslintrc.json') +module.exports = require('./.eslintrc.json') diff --git a/package.json b/package.json index d437ff62..f9c5f7eb 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "url": "git://github.com/standard/eslint-config-standard.git" }, "scripts": { - "lint": "eslint . --config=eslintrc.json", + "lint": "eslint .", "test": "npm run lint && tape test/*.js" }, "funding": [ diff --git a/test/validate-config.js b/test/validate-config.js index 665973ac..090d1a5b 100644 --- a/test/validate-config.js +++ b/test/validate-config.js @@ -1,16 +1,10 @@ -const eslint = require('eslint') +const { ESLint } = require('eslint') const test = require('tape') -test('load config in eslint to validate all rule syntax is correct', function (t) { - const CLIEngine = eslint.CLIEngine - - const cli = new CLIEngine({ - useEslintrc: false, - configFile: 'eslintrc.json' - }) - +test('load config in eslint to validate all rule syntax is correct', async function (t) { + const eslint = new ESLint() const code = 'const foo = 1\nconst bar = function () {}\nbar(foo)\n' - - t.equal(cli.executeOnText(code).errorCount, 0) + const [lintResult] = await eslint.lintText(code) + t.equal(lintResult.errorCount, 0) t.end() })