diff --git a/lib/linter/index.js b/lib/linter/index.js index 3d185910..afd91f82 100755 --- a/lib/linter/index.js +++ b/lib/linter/index.js @@ -10,7 +10,7 @@ const Hoek = require('@hapi/hoek'); const internals = {}; -exports.lint = function () { +exports.lint = async function () { const configuration = { ignore: true @@ -32,8 +32,8 @@ exports.lint = function () { let results; try { - const engine = new Eslint.CLIEngine(configuration); - results = engine.executeOnFiles(['.']); + const eslint = new Eslint.ESLint(configuration); + results = await eslint.lintFiles(['.']); } catch (ex) { results = { @@ -67,4 +67,11 @@ exports.lint = function () { }); }; -process.send(exports.lint()); +async function main () { + + const results = await exports.lint(); + process.send(results); +} + +main(); + diff --git a/lib/modules/coverage.js b/lib/modules/coverage.js index 3d4fe0d5..a32e8f43 100755 --- a/lib/modules/coverage.js +++ b/lib/modules/coverage.js @@ -18,7 +18,7 @@ const Transform = require('./transform'); const internals = { ext: Symbol.for('@hapi/lab/coverage/initialize'), _state: Symbol.for('@hapi/lab/coverage/_state'), - EslintEngine: new ESLint.CLIEngine({ baseConfig: Eslintrc }) + eslint: new ESLint.ESLint({ baseConfig: Eslintrc }) }; @@ -116,13 +116,13 @@ internals.escape = function (string) { internals.prime = function (extension) { - require.extensions[extension] = function (localModule, filename) { + require.extensions[extension] = async function (localModule, filename) { // We never want to instrument eslint configs in order to avoid infinite recursion if (Path.basename(filename, extension) !== '.eslintrc') { for (let i = 0; i < internals.state.patterns.length; ++i) { if (internals.state.patterns[i].test(filename.replace(/\\/g, '/'))) { - return localModule._compile(internals.instrument(filename), filename); + return localModule._compile(await internals.instrument(filename), filename); } } } @@ -133,7 +133,7 @@ internals.prime = function (extension) { }; -internals.instrument = function (filename) { +internals.instrument = async function (filename) { filename = filename.replace(/\\/g, '/'); @@ -334,7 +334,7 @@ internals.instrument = function (filename) { // Parse tree - const eslintConfig = internals.EslintEngine.getConfigForFile(filename); + const eslintConfig = await internals.eslint.calculateConfigForFile(filename); const tree = ESLintParser.parse(content, { ...eslintConfig.parserOptions, loc: true, @@ -540,7 +540,7 @@ exports.analyze = async function (options) { const filename = file.replace(/\\/g, '/'); if (pattern.test(filename)) { if (!report[filename]) { - internals.instrument(filename); + await internals.instrument(filename); } report[filename].source = internals.state.sources[filename] || []; diff --git a/package.json b/package.json index 240142dd..d6fa4960 100755 --- a/package.json +++ b/package.json @@ -19,13 +19,13 @@ ] }, "dependencies": { - "@babel/core": "^7.14.3", - "@babel/eslint-parser": "^7.14.3", + "@babel/core": "^7.15.8", + "@babel/eslint-parser": "^7.15.8", "@hapi/bossy": "5.x.x", "@hapi/eslint-plugin": "^5.1.0", "@hapi/hoek": "9.x.x", "diff": "4.x.x", - "eslint": "7.x.x", + "eslint": "8.x.x", "find-rc": "4.x.x", "globby": "10.x.x", "handlebars": "4.x.x", diff --git a/test/reporters.js b/test/reporters.js index e227fd61..27acde49 100755 --- a/test/reporters.js +++ b/test/reporters.js @@ -25,9 +25,9 @@ const it = lab.it; const expect = Code.expect; -describe('Reporter', () => { +describe('Reporter', async () => { - Lab.coverage.instrument({ coveragePath: Path.join(__dirname, './coverage/'), coverageExclude: 'exclude' }); + await Lab.coverage.instrument({ coveragePath: Path.join(__dirname, './coverage/'), coverageExclude: 'exclude' }); it('outputs to a stream', async () => {