Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint 8 support #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions bin/resmoke-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,35 @@ const path = require("path");
const util = require("util");

const program = require("commander");
const CLIEngine = require('eslint').CLIEngine;
const { ESLint } = require('eslint');

function localeCompare(str1, str2) {
return str1.localeCompare(str2);
}

function lint(files, ruleOptions) {
const cli = new CLIEngine({
async function lint(files, ruleOptions) {
const eslint = new ESLint({
// We don't use the top-level .eslintrc.yml file but we still enable ES6 features and
// MongoDB global variables ourselves.
useEslintrc: false,
envs: ["es6", "mongo"],

plugins: ["mongodb-server"],
rules: {"mongodb-server/resmoke-tags": ruleOptions},
overrideConfig: {
env: {
"es6": true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this line to "es2022": true match https://github.com/mongodb/mongo/blob/2cf2693a7846bb49b9e819c8be4863e096c85ebe/.eslintrc.yml#L2. Ditto line 15.

"mongo": true,
},
plugins: ["mongodb-server"],
rules: {"mongodb-server/resmoke-tags": ruleOptions},
parserOptions: {
"sourceType": "module",
"ecmaVersion": 2022,
}
},
fix: true,
});

const report = cli.executeOnFiles(files);
if (report.errorCount > 0) {
const report = await eslint.lintFiles(files);
const errorCount = report.reduce((acc, file) => acc + file.errorCount, 0);
if (errorCount > 0) {
// We don't attempt to make changes to the specified files if there are non-fixable errors.
console.error(util.inspect(report, {
showHidden: false,
Expand All @@ -34,7 +43,7 @@ function lint(files, ruleOptions) {
process.exit(2);
}

CLIEngine.outputFixes(report);
await ESLint.outputFixes(report);
return report;
}

Expand Down
Loading