Add .mjs to linting, switch from eslint-plugin-node (no longer maintained) to eslint-plugin-n, update suppressions.

This commit is contained in:
David Anson 2022-10-26 03:26:59 +00:00
parent a2b1353db5
commit 0294b9bcc8
9 changed files with 59 additions and 56 deletions

View file

@ -6,6 +6,7 @@
"extends": [ "extends": [
"eslint:all", "eslint:all",
"plugin:jsdoc/recommended", "plugin:jsdoc/recommended",
"plugin:n/recommended",
"plugin:unicorn/all" "plugin:unicorn/all"
], ],
"ignorePatterns": [ "ignorePatterns": [
@ -39,12 +40,22 @@
"example/*.js" "example/*.js"
], ],
"rules": { "rules": {
"node/no-extraneous-require": "off", "n/no-extraneous-require": "off",
"n/no-missing-require": "off",
"no-console": "off", "no-console": "off",
"no-invalid-this": "off", "no-invalid-this": "off",
"no-shadow": "off", "no-shadow": "off",
"object-property-newline": "off" "object-property-newline": "off"
} }
},
{
"files": [
"**/*.mjs"
],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
}
} }
], ],
"parserOptions": { "parserOptions": {
@ -54,7 +65,7 @@
"plugins": [ "plugins": [
"es", "es",
"jsdoc", "jsdoc",
"node", "n",
"unicorn" "unicorn"
], ],
"reportUnusedDisableDirectives": true, "reportUnusedDisableDirectives": true,
@ -101,6 +112,7 @@
"prefer-named-capture-group": "off", "prefer-named-capture-group": "off",
"prefer-template": "off", "prefer-template": "off",
"require-unicode-regexp": "off", "require-unicode-regexp": "off",
"sort-imports": "off",
"sort-keys": "off", "sort-keys": "off",
"space-before-function-paren": ["error", "never"], "space-before-function-paren": ["error", "never"],
"vars-on-top": "off", "vars-on-top": "off",
@ -150,47 +162,43 @@
"jsdoc/tag-lines": "error", "jsdoc/tag-lines": "error",
"jsdoc/valid-types": "error", "jsdoc/valid-types": "error",
"node/handle-callback-err": "error", "n/handle-callback-err": "error",
"node/no-callback-literal": "error", "n/no-callback-literal": "error",
"node/no-exports-assign": "error", "n/no-exports-assign": "error",
"node/no-extraneous-import": "error", "n/no-extraneous-import": "error",
"node/no-extraneous-require": "error", "n/no-extraneous-require": "error",
"node/no-missing-import": "error", "n/no-missing-import": "error",
"node/no-missing-require": "off", "n/no-missing-require": "error",
"node/no-new-require": "error", "n/no-new-require": "error",
"node/no-path-concat": "error", "n/no-path-concat": "error",
"node/no-process-exit": "error", "n/no-process-exit": "error",
"node/no-unpublished-bin": "error", "n/no-unpublished-bin": "error",
"node/no-unpublished-import": "error", "n/no-unpublished-import": "error",
"node/no-unpublished-require": "error", "n/no-unpublished-require": "error",
"node/no-unsupported-features/es-builtins": "error", "n/no-unsupported-features/es-builtins": "error",
"node/no-unsupported-features/es-syntax": "error", "n/no-unsupported-features/es-syntax": "error",
"node/no-unsupported-features/node-builtins": ["error", { "n/no-unsupported-features/node-builtins": "error",
"ignores": [ "n/process-exit-as-throw": "error",
"fs.promises" "n/shebang": "error",
] "n/no-deprecated-api": "error",
}], "n/callback-return": "error",
"node/process-exit-as-throw": "error", "n/exports-style": "error",
"node/shebang": "error", "n/file-extension-in-import": "error",
"node/no-deprecated-api": "error", "n/global-require": "off",
"node/callback-return": "error", "n/no-mixed-requires": "error",
"node/exports-style": "error", "n/no-process-env": "error",
"node/file-extension-in-import": "error", "n/no-restricted-import": "error",
"node/global-require": "off", "n/no-restricted-require": "error",
"node/no-mixed-requires": "error", "n/no-sync": "off",
"node/no-process-env": "error", "n/prefer-global/buffer": "error",
"node/no-restricted-import": "error", "n/prefer-global/console": "error",
"node/no-restricted-require": "error", "n/prefer-global/process": "error",
"node/no-sync": "off", "n/prefer-global/text-decoder": "error",
"node/prefer-global/buffer": "error", "n/prefer-global/text-encoder": "error",
"node/prefer-global/console": "error", "n/prefer-global/url-search-params": "error",
"node/prefer-global/process": "error", "n/prefer-global/url": "error",
"node/prefer-global/text-decoder": "error", "n/prefer-promises/dns": "error",
"node/prefer-global/text-encoder": "error", "n/prefer-promises/fs": "error",
"node/prefer-global/url-search-params": "error",
"node/prefer-global/url": "error",
"node/prefer-promises/dns": "error",
"node/prefer-promises/fs": "off",
"unicorn/better-regex": "off", "unicorn/better-regex": "off",
"unicorn/consistent-function-scoping": "off", "unicorn/consistent-function-scoping": "off",

View file

@ -43,7 +43,7 @@
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint", "example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install", "docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install",
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade", "docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade",
"lint": "eslint --max-warnings 0 .", "lint": "eslint --ext .js,.mjs --max-warnings 0 .",
"lint-test-repos": "ava --timeout=5m test/markdownlint-test-repos.js", "lint-test-repos": "ava --timeout=5m test/markdownlint-test-repos.js",
"serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration", "serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration",
"test": "ava test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js", "test": "ava test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js",
@ -65,7 +65,7 @@
"eslint": "8.26.0", "eslint": "8.26.0",
"eslint-plugin-es": "4.1.0", "eslint-plugin-es": "4.1.0",
"eslint-plugin-jsdoc": "39.3.24", "eslint-plugin-jsdoc": "39.3.24",
"eslint-plugin-node": "11.1.0", "eslint-plugin-n": "15.3.0",
"eslint-plugin-unicorn": "44.0.2", "eslint-plugin-unicorn": "44.0.2",
"globby": "13.1.2", "globby": "13.1.2",
"js-yaml": "4.1.0", "js-yaml": "4.1.0",

View file

@ -12,7 +12,6 @@ const [ command, ...args ] = process.argv.slice(2);
const [ src, dest ] = args; const [ src, dest ] = args;
await fs.copyFile(src, dest); await fs.copyFile(src, dest);
} else if (command === "delete") { } else if (command === "delete") {
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { globby } = await import("globby"); const { globby } = await import("globby");
await Promise.all( await Promise.all(
args.flatMap( args.flatMap(

View file

@ -8,7 +8,6 @@ const markdownlint = require("../lib/markdownlint");
// Parses all Markdown files in all package dependencies // Parses all Markdown files in all package dependencies
test("parseAllFiles", async(t) => { test("parseAllFiles", async(t) => {
t.plan(1); t.plan(1);
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { globby } = await import("globby"); const { globby } = await import("globby");
const files = await globby("**/*.{md,markdown}"); const files = await globby("**/*.{md,markdown}");
await markdownlint.promises.markdownlint({ files }); await markdownlint.promises.markdownlint({ files });

View file

@ -22,9 +22,7 @@ const readConfigPromise = promisify(markdownlint.readConfig);
*/ */
async function lintTestRepo(t, globPatterns, configPath, ignoreRes) { async function lintTestRepo(t, globPatterns, configPath, ignoreRes) {
t.plan(1); t.plan(1);
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { globby } = await import("globby"); const { globby } = await import("globby");
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { "default": stripJsonComments } = await import("strip-json-comments"); const { "default": stripJsonComments } = await import("strip-json-comments");
const jsoncParse = (json) => { const jsoncParse = (json) => {
const config = JSON.parse(stripJsonComments(json)); const config = JSON.parse(stripJsonComments(json));

View file

@ -1081,7 +1081,6 @@ test("validateConfigSchemaAppliesToUnknownProperties", (t) => {
test("validateConfigExampleJson", async(t) => { test("validateConfigExampleJson", async(t) => {
t.plan(2); t.plan(2);
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { "default": stripJsonComments } = await import("strip-json-comments"); const { "default": stripJsonComments } = await import("strip-json-comments");
// Validate JSONC // Validate JSONC
const fileJson = ".markdownlint.jsonc"; const fileJson = ".markdownlint.jsonc";
@ -1357,7 +1356,6 @@ test("configParsersJSON", async(t) => {
test("configParsersJSONC", async(t) => { test("configParsersJSONC", async(t) => {
t.plan(1); t.plan(1);
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { "default": stripJsonComments } = await import("strip-json-comments"); const { "default": stripJsonComments } = await import("strip-json-comments");
const options = { const options = {
"strings": { "strings": {
@ -1401,7 +1399,6 @@ test("configParsersYAML", async(t) => {
test("configParsersTOML", async(t) => { test("configParsersTOML", async(t) => {
t.plan(1); t.plan(1);
// eslint-disable-next-line node/no-unsupported-features/es-syntax
const { "default": stripJsonComments } = await import("strip-json-comments"); const { "default": stripJsonComments } = await import("strip-json-comments");
const options = { const options = {
"strings": { "strings": {

View file

@ -12,7 +12,9 @@ const strings = {
const start = new Date(); const start = new Date();
for (let i = 0; i < 250; i++) { for (let i = 0; i < 250; i++) {
await markdownlint({strings}); // eslint-disable-next-line no-await-in-loop
await markdownlint({ strings });
} }
const end = new Date(); const end = new Date();
// eslint-disable-next-line no-console
console.log(`Elapsed: ${end - start}`); console.log(`Elapsed: ${end - start}`);

View file

@ -17,7 +17,7 @@ const languageJavaScript = /js|javascript/i;
function cleanJsdocRulesFromEslintConfig(config) { function cleanJsdocRulesFromEslintConfig(config) {
const cleanedConfig = { ...config }; const cleanedConfig = { ...config };
for (const rule in config.rules) { for (const rule in config.rules) {
if (/^(es|jsdoc|node|unicorn)\//.test(rule)) { if (/^(es|jsdoc|n|unicorn)\//.test(rule)) {
delete cleanedConfig.rules[rule]; delete cleanedConfig.rules[rule];
} }
} }

View file

@ -10,8 +10,8 @@ module.exports = {
"tags": [ "test", "validate", "json" ], "tags": [ "test", "validate", "json" ],
"asynchronous": true, "asynchronous": true,
"function": async(params, onError) => { "function": async(params, onError) => {
// eslint-disable-next-line max-len, node/no-unsupported-features/es-syntax const { "default": stripJsonComments } =
const { "default": stripJsonComments } = await import("strip-json-comments"); await import("strip-json-comments");
filterTokens(params, "fence", (fence) => { filterTokens(params, "fence", (fence) => {
if (/jsonc?/i.test(fence.info)) { if (/jsonc?/i.test(fence.info)) {
try { try {