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

chore: switch to eslint flat config #73

Merged
merged 3 commits into from
Aug 31, 2023
Merged
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
24 changes: 0 additions & 24 deletions .eslintrc.cjs

This file was deleted.

20 changes: 20 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import eslintConfigESLint from "eslint-config-eslint";
import globals from "globals";

export default [
{
ignores: [
"coverage/",
"tests/fixtures/"
]
},
...eslintConfigESLint,
{
files: ["tests/**"],
languageOptions: {
globals: {
...globals.mocha
}
}
}
];
1 change: 0 additions & 1 deletion lib/init/config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ async function writeYAMLConfigFile(config, filePath) {
debug(`Writing YAML config file: ${filePath}`);

// lazy load YAML to improve performance when not used
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const yaml = await import("js-yaml");

const content = yaml.dump(config, { sortKeys: true });
Expand Down
4 changes: 3 additions & 1 deletion lib/init/config-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ function askInstallModules(modules) {
/**
* Ask use a few questions on command prompt
* @returns {Promise<void>} The promise with the result of the prompt
* @throws {Error} If `package.json` file doesn't exist.
*/
function promptUser() {
const packageJsonExists = npmUtils.checkPackageJson();
Expand Down Expand Up @@ -598,7 +599,8 @@ function promptUser() {
}

/* istanbul ignore next */
/** an wrapper for promptUser
/**
* an wrapper for promptUser
* @returns {void}
*/
function initializeConfig() {
Expand Down
3 changes: 1 addition & 2 deletions lib/init/npm-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ function findPackageJson(startDir) {
function installSyncSaveDev(packages, packageManager = "npm") {
const packageList = Array.isArray(packages) ? packages : [packages];
const installCmd = packageManager === "yarn" ? "add" : "install";
const installProcess = spawn.sync(packageManager, [installCmd, "-D"].concat(packageList),
{ stdio: "inherit" });
const installProcess = spawn.sync(packageManager, [installCmd, "-D"].concat(packageList), { stdio: "inherit" });
const error = installProcess.error;

if (error && error.code === "ENOENT") {
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"access": "public"
},
"scripts": {
"lint": "eslint .",
"lint": "eslint . --report-unused-disable-directives",
"release:generate:latest": "eslint-generate-release",
"release:generate:alpha": "eslint-generate-prerelease alpha",
"release:generate:beta": "eslint-generate-prerelease beta",
Expand All @@ -55,13 +55,12 @@
"devDependencies": {
"c8": "^7.10.0",
"chai": "^4.3.4",
"eslint": "^8.2.0",
"eslint-config-eslint": "^7.0.0",
"eslint-plugin-jsdoc": "^37.0.3",
"eslint-plugin-node": "^11.1.0",
"eslint": "^8.48.0",
"eslint-config-eslint": "^9.0.0",
"eslint-release": "^3.2.0",
"esmock": "^2.2.3",
"espree": "^9.0.0",
"globals": "^13.21.0",
"lint-staged": "^12.1.2",
"memfs": "^3.4.0",
"mocha": "^9.1.3",
Expand Down
6 changes: 3 additions & 3 deletions tests/init/config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("ConfigFile", () => {

it(`should write a file through fs when a ${fileType} path is passed`, async () => {
const fakeFS = {
writeFileSync: () => {}
writeFileSync() {}
};

sinon.mock(fakeFS).expects("writeFileSync").withExactArgs(
Expand All @@ -84,7 +84,7 @@ describe("ConfigFile", () => {

it("should include a newline character at EOF", async () => {
const fakeFS = {
writeFileSync: () => {}
writeFileSync() {}
};

sinon.mock(fakeFS).expects("writeFileSync").withExactArgs(
Expand All @@ -103,7 +103,7 @@ describe("ConfigFile", () => {

it("should run 'eslint --fix' to make sure js config files match linting rules", async () => {
const fakeFS = {
writeFileSync: () => {}
writeFileSync() {}
};

const singleQuoteConfig = {
Expand Down
2 changes: 1 addition & 1 deletion tests/init/config-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("configInitializer", () => {

// copy into clean area so as not to get "infected" by this project's .eslintrc files
before(() => {
const __filename = fileURLToPath(import.meta.url); // eslint-disable-line no-underscore-dangle
const __filename = fileURLToPath(import.meta.url); // eslint-disable-line no-underscore-dangle -- Conventional

fixtureDir = path.join(__filename, "../../../tmp/eslint/fixtures/config-initializer");
localInstalledEslintDir = path.join(fixtureDir, "./node_modules/eslint");
Expand Down
Loading