From 3076e9985d34070923957d2fa18a5771818f5f9b Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Wed, 15 Sep 2021 02:05:42 +0900 Subject: [PATCH] Update configuration for ESM (#133) We are moving to ESM on the `stylelint/stylelint` repo: https://github.com/stylelint/stylelint/issues/5291 --- .eslintrc.js | 8 ++++---- __tests__/index.test.js | 4 +++- index.js | 1 + package-lock.json | 13 +------------ package.json | 3 +-- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5f81c57..21817a6 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,18 +1,19 @@ "use strict"; +// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS. module.exports = { parserOptions: { ecmaVersion: 2019, + sourceType: "module", }, env: { es6: true, node: true, }, - plugins: ["eslint-comments", "jest", "node", "sort-requires"], extends: [ "eslint:recommended", "plugin:eslint-comments/recommended", - "plugin:node/recommended", + "plugin:node/recommended-module", "plugin:jest/recommended", "plugin:jest/style", "prettier", @@ -111,7 +112,6 @@ module.exports = { "prefer-rest-params": "error", "prefer-spread": "error", "prefer-template": "error", - "sort-requires/sort-requires": "error", - strict: ["error", "global"], + "sort-imports": ["error", { allowSeparatedGroups: true }], }, }; diff --git a/__tests__/index.test.js b/__tests__/index.test.js index a58e75b..b96a0ac 100644 --- a/__tests__/index.test.js +++ b/__tests__/index.test.js @@ -1,6 +1,7 @@ "use strict"; -const config = require("../"); +// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS. +const config = require("../index"); it("test basic properties of config", () => { expect(isObject(config.parserOptions)).toBeTruthy(); @@ -9,6 +10,7 @@ it("test basic properties of config", () => { }); it("load config in ESLint to validate all rule syntax is correct", () => { + // eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS. const CLIEngine = require("eslint").CLIEngine; const cli = new CLIEngine({ diff --git a/index.js b/index.js index 04feb0e..3750a2c 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ "use strict"; +// eslint-disable-next-line no-undef -- Keep backward compatibility with CommonJS. module.exports = require("./.eslintrc.js"); diff --git a/package-lock.json b/package-lock.json index 18507af..8b69dbd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,8 +11,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-jest": "^24.3.6", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-sort-requires": "^2.1.0" + "eslint-plugin-node": "^11.1.0" }, "devDependencies": { "eslint": "^7.27.0", @@ -3050,11 +3049,6 @@ "node": ">=8.10.0" } }, - "node_modules/eslint-plugin-sort-requires": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sort-requires/-/eslint-plugin-sort-requires-2.1.0.tgz", - "integrity": "sha1-PvrZSNyDeYIZ6An1QGfEDlVESGE=" - }, "node_modules/eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", @@ -12128,11 +12122,6 @@ "semver": "^6.1.0" } }, - "eslint-plugin-sort-requires": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-sort-requires/-/eslint-plugin-sort-requires-2.1.0.tgz", - "integrity": "sha1-PvrZSNyDeYIZ6An1QGfEDlVESGE=" - }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", diff --git a/package.json b/package.json index 7d33912..7cc2faa 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,7 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-jest": "^24.3.6", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-sort-requires": "^2.1.0" + "eslint-plugin-node": "^11.1.0" }, "publishConfig": { "access": "public"