diff --git a/.eslintignore b/.eslintignore index 4713e63..c2658d7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1 @@ node_modules/ -temp/ -*/templates/* diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index af897b9..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; - -module.exports = { - root: true, - parserOptions: { - ecmaVersion: 2020 - }, - extends: [ - "eslint" - ], - env: { - node: true - }, - overrides: [ - { - files: ["tests/**/*.js"], - env: { mocha: true } - } - ] -}; diff --git a/app/index.js b/app/index.js index 9fd6a60..80bc317 100644 --- a/app/index.js +++ b/app/index.js @@ -15,15 +15,20 @@ import PluginGenerator from "../plugin/index.js"; import { fileURLToPath } from "node:url"; import path from "node:path"; -const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle +/* eslint-disable no-underscore-dangle -- cjs convention */ +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const RULE_GENERATOR_PATH = path.join(__dirname, "..", "rule", "index.js"); const PLUGIN_GENERATOR_PATH = path.join(__dirname, "..", "plugin", "index.js"); +/* eslint-enable no-underscore-dangle -- cjs convention*/ //------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------ +/** + * + */ export default class extends Generator { async prompting() { const answers = await this.prompt({ diff --git a/eslint.config.js b/eslint.config.js index 064f294..c0bfcd6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,8 +1,15 @@ -"use strict"; +import globals from "globals"; import eslintConfigESLint from "eslint-config-eslint"; export default [ ...eslintConfigESLint, - {files: ["tests/**/*.js"], - languageOptions: { globals: globals.mocha }} + { + name: "generator-eslint/global-ignores", + ignores: ["temp/", "*/templates/*"] + }, + { + name: "generator-eslint/test-files", + files: ["tests/**/*.js"], + languageOptions: { globals: globals.mocha } + } ]; diff --git a/package.json b/package.json index ef84748..485b1a2 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "scripts": { "lint": "npm-run-all --continue-on-error --aggregate-output --parallel lint:*", "lint:docs": "markdownlint \"**/*.md\"", - "lint:js": "eslint --report-unused-disable-directives .", + "lint:js": "eslint .", "release:generate:latest": "eslint-generate-release", "release:generate:alpha": "eslint-generate-prerelease alpha", "release:generate:beta": "eslint-generate-prerelease beta", diff --git a/plugin/index.js b/plugin/index.js index 048957d..3e4c145 100644 --- a/plugin/index.js +++ b/plugin/index.js @@ -21,6 +21,9 @@ import { isPluginId, isRequired } from "../lib/validators.js"; // Constructor //------------------------------------------------------------------------------ +/** + * + */ export default class extends Generator { async prompting() { const prompts = [{ diff --git a/plugin/templates/_eslint.config.mjs b/plugin/templates/_eslint.config.mjs index f35954f..f041856 100644 --- a/plugin/templates/_eslint.config.mjs +++ b/plugin/templates/_eslint.config.mjs @@ -6,4 +6,4 @@ export default [ pluginJs.configs.recommended, pluginNode.configs["flat/recommended"], eslintPlugin.configs["flat/recommended"] -] +]; diff --git a/rule/index.js b/rule/index.js index 84c9dd4..0e45840 100644 --- a/rule/index.js +++ b/rule/index.js @@ -19,6 +19,9 @@ import { isRuleId, isRequired } from "../lib/validators.js"; // Constructor //------------------------------------------------------------------------------ +/** + * + */ export default class extends Generator { async prompting() { const prompts = [ diff --git a/tests/app/index.js b/tests/app/index.js index 56c8b6b..8f95868 100644 --- a/tests/app/index.js +++ b/tests/app/index.js @@ -15,12 +15,13 @@ import path from "node:path"; //------------------------------------------------------------------------------ // Tests //------------------------------------------------------------------------------ - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle +/* eslint-disable no-underscore-dangle -- cjs convention */ +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const APP_GENERATOR_PATH = path.join(__dirname, "..", "..", "app", "index.js"); const RULE_GENERATOR_PATH = path.join(__dirname, "..", "..", "rule", "index.js"); const PLUGIN_GENERATOR_PATH = path.join(__dirname, "..", "..", "plugin", "index.js"); +/* eslint-enable no-underscore-dangle -- cjs convention */ describe("ESLint Main Generator", () => { describe("User answers with Plugin", () => { diff --git a/tests/plugin/index.js b/tests/plugin/index.js index 4d10bd9..34ce856 100644 --- a/tests/plugin/index.js +++ b/tests/plugin/index.js @@ -16,7 +16,7 @@ import path from "node:path"; // Tests //------------------------------------------------------------------------------ -const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle -- cjs convention const PLUGIN_GENERATOR_PATH = path.join(__dirname, "..", "..", "plugin", "index.js"); diff --git a/tests/rule/index.js b/tests/rule/index.js index fa822ab..c7fc6d8 100644 --- a/tests/rule/index.js +++ b/tests/rule/index.js @@ -17,7 +17,7 @@ import path from "node:path"; // Tests //------------------------------------------------------------------------------ -const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // eslint-disable-line no-underscore-dangle -- cjs convention const RULE_GENERATOR_PATH = path.join(__dirname, "..", "..", "rule", "index.js"); diff --git a/tests/test-load.js b/tests/test-load.js index 56943a7..5400f0c 100644 --- a/tests/test-load.js +++ b/tests/test-load.js @@ -5,8 +5,14 @@ import assert from "node:assert"; -// eslint-disable-next-line func-style, node/no-unsupported-features/es-syntax -- https://github.com/mysticatea/eslint-plugin-node/issues/250 -const importFresh = async modulePath => import(`${modulePath}?x=${new Date()}`); +/** + * Import a module fresh every time. + * @param {string} modulePath The path to the module to import. + * @returns {Promise<*>} The imported module. + */ +async function importFresh(modulePath) { + return import(`${modulePath}?x=${new Date()}`); +} describe("eslint generator", () => { it("can be imported without blowing up", () => {