From 466075363d84a42b3b594acd2c58cbada0cba091 Mon Sep 17 00:00:00 2001 From: David Anson Date: Fri, 19 Apr 2024 20:05:16 -0700 Subject: [PATCH] Update to ESLint 9's "flat" configuration file format. --- .eslintrc.json | 90 ------------------------------------- eslint.config.mjs | 61 +++++++++++++++++++++++++ package.json | 3 +- test/fs-mock.js | 2 - webworker/webworker-test.js | 3 +- 5 files changed, 64 insertions(+), 95 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f8e9de7a..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "parserOptions": { - "ecmaVersion": 2020, - "sourceType": "script" - }, - "env": { - "node": true, - "es6": true - }, - "plugins": [ - "jsdoc", - "n", - "unicorn" - ], - "extends": [ - "eslint:all", - "plugin:jsdoc/recommended", - "plugin:n/recommended", - "plugin:unicorn/all" - ], - "ignorePatterns": [ - "test/*/**", - "webworker/markdownlint-cli2-webworker.js", - "webworker/setImmediate.js" - ], - "reportUnusedDisableDirectives": true, - "rules": { - "capitalized-comments": "off", - "complexity": "off", - "guard-for-in": "off", - "id-length": "off", - "max-lines-per-function": "off", - "max-lines": "off", - "max-params": "off", - "max-statements": "off", - "multiline-comment-style": ["error", "separate-lines"], - "no-console": "off", - "no-magic-numbers": "off", - "no-plusplus": "off", - "no-ternary": "off", - "no-undef-init": "off", - "no-undefined": "off", - "one-var": "off", - "require-atomic-updates": "off", - "sort-keys": "off", - - "n/callback-return": "error", - "n/exports-style": "error", - "n/file-extension-in-import": "error", - "n/global-require": "off", - "n/handle-callback-err": "error", - "n/no-callback-literal": "error", - "n/no-deprecated-api": "error", - "n/no-exports-assign": "error", - "n/no-extraneous-import": "error", - "n/no-extraneous-require": "error", - "n/no-missing-import": "error", - "n/no-missing-require": "error", - "n/no-mixed-requires": "error", - "n/no-new-require": "error", - "n/no-path-concat": "error", - "n/no-process-env": "error", - "n/no-process-exit": "error", - "n/no-restricted-import": "error", - "n/no-restricted-require": "error", - "n/no-sync": "error", - "n/no-unpublished-bin": "error", - "n/no-unpublished-import": "error", - "n/no-unpublished-require": "error", - "n/no-unsupported-features/es-builtins": "error", - "n/no-unsupported-features/es-syntax": "error", - "n/no-unsupported-features/node-builtins": "error", - "n/prefer-global/buffer": "error", - "n/prefer-global/console": "error", - "n/prefer-global/process": "error", - "n/prefer-global/text-decoder": "error", - "n/prefer-global/text-encoder": "error", - "n/prefer-global/url-search-params": "error", - "n/prefer-global/url": "error", - "n/prefer-promises/dns": "error", - "n/prefer-promises/fs": "error", - "n/process-exit-as-throw": "error", - "n/shebang": "error", - - "unicorn/no-null": "off", - "unicorn/prefer-module": "off", - "unicorn/prefer-string-replace-all": "off", - "unicorn/prevent-abbreviations": "off" - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..438be774 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,61 @@ +import js from "@eslint/js"; +import eslintPluginJsdoc from "eslint-plugin-jsdoc"; +import eslintPluginNode from "eslint-plugin-n"; +import eslintPluginUnicorn from "eslint-plugin-unicorn"; + +export default [ + js.configs.all, + eslintPluginJsdoc.configs['flat/recommended'], + eslintPluginNode.configs["flat/recommended"], + eslintPluginUnicorn.configs["flat/all"], + { + "ignores": [ + "test/*/**", + "webworker/markdownlint-cli2-webworker.js", + "webworker/setImmediate.js" + ] + }, + { + "languageOptions": { + "sourceType": "commonjs" + }, + "linterOptions": { + "reportUnusedDisableDirectives": true + }, + "rules": { + "capitalized-comments": "off", + "complexity": "off", + "guard-for-in": "off", + "id-length": "off", + "max-lines-per-function": "off", + "max-lines": "off", + "max-params": "off", + "max-statements": "off", + "multiline-comment-style": [ "error", "separate-lines" ], + "no-console": "off", + "no-magic-numbers": "off", + "no-plusplus": "off", + "no-ternary": "off", + "no-undef-init": "off", + "no-undefined": "off", + "no-useless-assignment": "off", + "one-var": "off", + "require-atomic-updates": "off", + "sort-keys": "off", + "sort-imports": "off", + + "unicorn/no-null": "off", + "unicorn/prefer-module": "off", + "unicorn/prefer-string-replace-all": "off", + "unicorn/prevent-abbreviations": "off" + } + }, + { + "files": [ + "**/*.mjs" + ], + "languageOptions": { + "sourceType": "module" + } + } +]; diff --git a/package.json b/package.json index 538f30ba..14ec2d82 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "build-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2:v$VERSION -f docker/Dockerfile --label org.opencontainers.image.version=v$VERSION .", "build-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2-rules:v$VERSION -f docker/Dockerfile-rules --build-arg VERSION=v$VERSION --label org.opencontainers.image.version=v$VERSION .", "ci": "npm-run-all --continue-on-error --parallel test-cover lint schema && git diff --exit-code", - "lint": "eslint --max-warnings 0 --no-eslintrc --config .eslintrc.json .", + "lint": "eslint --max-warnings 0", "lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile", "lint-watch": "git ls-files | entr npm run lint", "schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat", @@ -76,6 +76,7 @@ "micromatch": "4.0.5" }, "devDependencies": { + "@eslint/js": "9.1.1", "@iktakahiro/markdown-it-katex": "4.0.1", "ajv": "8.12.0", "ava": "6.1.2", diff --git a/test/fs-mock.js b/test/fs-mock.js index dc3267bd..8f66b4f3 100644 --- a/test/fs-mock.js +++ b/test/fs-mock.js @@ -1,7 +1,5 @@ // @ts-check -/* eslint-disable n/prefer-promises/fs */ - "use strict"; const fs = require("node:fs"); diff --git a/webworker/webworker-test.js b/webworker/webworker-test.js index c84459c9..7a6ba80f 100644 --- a/webworker/webworker-test.js +++ b/webworker/webworker-test.js @@ -1,7 +1,6 @@ "use strict"; -/* eslint-env qunit */ -/* globals markdownlintCli2, FsVirtual */ +/* globals markdownlintCli2, FsVirtual, QUnit */ const md009 = "# Title\n\nText \n"; const md010 = "# Title\n\n\tText\n";