From adf8da85e93bf68dbaa1dab3f9049b0154e486f9 Mon Sep 17 00:00:00 2001 From: Thomas Gideon Date: Mon, 24 Jun 2024 17:47:03 -0400 Subject: [PATCH] Migrate eslint to flat config --- .eslintignore | 2 -- .eslintrc.js | 10 ---------- eslint.config.mjs | 27 +++++++++++++++++++++++++++ jest.config.js | 1 + package.json | 4 ++-- src/__test__/guards.test.ts | 2 -- src/index.ts | 1 - 7 files changed, 30 insertions(+), 17 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index de4d1f0..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -dist -node_modules diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 51bade8..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,10 +0,0 @@ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: ["@typescript-eslint"], - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - ], -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..702d5a7 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,27 @@ +import { FlatCompat } from "@eslint/eslintrc"; +import path from "path"; +import { fileURLToPath } from "url"; +import ts from "@typescript-eslint/eslint-plugin"; +import js from "@eslint/js"; +import parser from "@typescript-eslint/parser"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const compat = new FlatCompat({ + baseDirectory: __dirname +}); + +export default [ + js.configs.recommended, + ...compat.extends("plugin:@typescript-eslint/recommended"), + ...compat.extends("prettier"), + { + ignores: [ "jest.config.js", "node_modules/*" ], + files: [ "**/*.ts" ], + languageOptions: { + parser: parser, + }, + plugins: { "@typescript-eslint": ts }, + } +]; diff --git a/jest.config.js b/jest.config.js index 6e561f2..837d0cd 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,4 @@ +/* eslint-disable */ const { compilerOptions } = require("./tsconfig.json"); /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ diff --git a/package.json b/package.json index 15a08b1..86aaccc 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ }, "scripts": { "clean": "yarn cache clean && rm -rf dist", - "lint": "yarn run eslint . --ext .ts", - "lint:fix": "yarn run eslint --fix . --ext .ts", + "lint": "yarn run eslint .", + "lint:fix": "yarn run eslint --fix .", "format:check": "yarn run prettier --check src/**", "format": "yarn run prettier --write src/**", "test": "yarn jest", diff --git a/src/__test__/guards.test.ts b/src/__test__/guards.test.ts index 5d9f754..cf37d20 100644 --- a/src/__test__/guards.test.ts +++ b/src/__test__/guards.test.ts @@ -2,7 +2,6 @@ import { Err, Ok } from ".."; import { isResult, __internals } from "../guards"; describe("guards.ts", () => { - /* eslint-disable @typescript-eslint/no-empty-function */ const combinators = { and: () => {}, andThen: () => {}, @@ -16,7 +15,6 @@ describe("guards.ts", () => { yieldOr: () => {}, yieldOrElse: () => {}, }; - /* eslint-enable */ const mockSuccess = { kind: "ok", diff --git a/src/index.ts b/src/index.ts index dacabb3..6542ae5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -213,7 +213,6 @@ export namespace Result { return this; } - // eslint-disable-next-line @typescript-eslint/no-unused-vars yieldOr(_: U, f: (t: T) => U): Result { return this.yield(f); }