From 54af7ba44ca7893e2e8b6e0124b9ae5270f1073f Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Wed, 16 Mar 2022 14:48:38 +0900 Subject: [PATCH 1/3] Applied the new API with the latest eslint --- CHANGELOG.md | 6 ++++++ get-config.js | 24 +++++++++++++++++++++++- global-resolver.js | 3 +-- npm-shrinkwrap.json | 26 +++++++++++++++++++++++++- package.json | 3 +++ 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1743fa..77e8462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The following is a curated list of changes in the Enact proxy ESLint config: +## [unreleased] + +### Fixed + +- Applied the new API to call ESLint module resolver correctly with the latest eslint. + ## [1.0.3] (December 28, 2021) No significant changes. diff --git a/get-config.js b/get-config.js index 8f4a216..c0e5953 100644 --- a/get-config.js +++ b/get-config.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const semver = require('semver'); const {npmGlobalModules, yarnGlobalModules, supportGlobalResolving} = require('./global-resolver'); // Find first parent module from the accessing ESLint. @@ -29,7 +30,28 @@ function getGlobalConfig({ ...search.map(dir => path.join(dir, 'eslint', 'lib', 'shared', 'relative-module-resolver.js')) ].find(dir => fs.existsSync(dir)); if (eslintResolverPath) { - supportGlobalResolving(eslintResolverPath, search); + let eslintResolver; + + if (eslintResolverPath.includes('eslintrc')) { + const eslintrcPath = path.join(eslintResolverPath, '..', '..', '..'); + const version = require(path.join(eslintrcPath, 'package.json')).version; + if (semver.gte(version, '0.4.1')) { + const { + Legacy: { + ModuleResolver + } + } = require(eslintrcPath); + eslintResolver = ModuleResolver; + } else if (semver.gte(version, '0.2.0')) { + eslintResolver = require(eslintResolverPath); + } else { + eslintResolver = require(path.join(eslintrcPath, '..', '..', '..', 'lib', 'shared', 'relative-module-resolver.js')); + } + } else { + eslintResolver = require(eslintResolverPath); + } + + supportGlobalResolving(eslintResolver, search); } // If eslint/lib/shared/relative-module-resolver.js does not exist, then // our global resolving support cannot be patched in. diff --git a/global-resolver.js b/global-resolver.js index e3d9f69..1c2d040 100644 --- a/global-resolver.js +++ b/global-resolver.js @@ -23,8 +23,7 @@ const npmGlobalModules = () => execSync('npm root -g'); const yarnGlobalModules = () => execSync('yarn global dir'); -const supportGlobalResolving = (resolverFile, globalPaths) => { - const resolver = require(resolverFile); +const supportGlobalResolving = (resolver, globalPaths) => { const doResolve = resolver.resolve; if (!Array.isArray(globalPaths)) globalPaths = [globalPaths]; resolver.resolve = function(moduleName, relativeToPath) { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d916daa..9f8ef0c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,5 +1,29 @@ { "name": "eslint-config-enact-proxy", "version": "1.0.3", - "lockfileVersion": 1 + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + } + } } diff --git a/package.json b/package.json index 26147b2..397330e 100644 --- a/package.json +++ b/package.json @@ -12,5 +12,8 @@ "scripts": { "lint": "eslint .", "fix": "eslint . --fix" + }, + "dependencies": { + "semver": "^7.3.5" } } From a4f13ce1f64186162c886730121cc30f54fe4d62 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Wed, 16 Mar 2022 15:00:24 +0900 Subject: [PATCH 2/3] modify version statement --- get-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-config.js b/get-config.js index c0e5953..21951c4 100644 --- a/get-config.js +++ b/get-config.js @@ -42,7 +42,7 @@ function getGlobalConfig({ } } = require(eslintrcPath); eslintResolver = ModuleResolver; - } else if (semver.gte(version, '0.2.0')) { + } else if (semver.gte(version, '0.2.2')) { eslintResolver = require(eslintResolverPath); } else { eslintResolver = require(path.join(eslintrcPath, '..', '..', '..', 'lib', 'shared', 'relative-module-resolver.js')); From 357e2056e892ab57f13405853cddcb37b196deb7 Mon Sep 17 00:00:00 2001 From: "taeyoung.hong" Date: Mon, 11 Apr 2022 16:51:44 +0900 Subject: [PATCH 3/3] 1.0.4 release --- CHANGELOG.md | 2 +- README.md | 2 +- npm-shrinkwrap.json | 24 ++++++++---------------- package.json | 4 ++-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e8462..e1142f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ The following is a curated list of changes in the Enact proxy ESLint config: -## [unreleased] +## [1.0.4] (April 11, 2022) ### Fixed diff --git a/README.md b/README.md index 9894c13..8486771 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ For more information (including editor/IDE setup), please see the [Enact ESLint Unless otherwise specified, all content, including all source code files and documentation files in this repository are: -Copyright (c) 2020 LG Electronics +Copyright (c) 2020-2022 LG Electronics Unless otherwise specified or set forth in the NOTICE file, all content, including all source code files and documentation files in this repository are: diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9f8ef0c..afb439a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,29 +1,21 @@ { "name": "eslint-config-enact-proxy", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "requires": { - "yallist": "^4.0.0" - } + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.8.1.tgz", + "integrity": "sha512-E1v547OCgJvbvevfjgK9sNKIVXO96NnsTsFPBlg4ZxjhsJSODoH9lk8Bm0OxvHNm6Vm5Yqkl/1fErDxhYL8Skg==" }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.6.tgz", + "integrity": "sha512-HZWqcgwLsjaX1HBD31msI/rXktuIhS+lWvdE4kN9z+8IVT4Itc7vqU2WvYsyD6/sjYCt4dEKH/m1M3dwI9CC5w==", "requires": { - "lru-cache": "^6.0.0" + "lru-cache": "^7.4.0" } - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } } diff --git a/package.json b/package.json index 397330e..2a6b9f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-enact-proxy", - "version": "1.0.3", + "version": "1.0.4", "description": "ESLint proxy config for global Enact ruleset", "main": "index.js", "author": "Jason Robitaille ", @@ -14,6 +14,6 @@ "fix": "eslint . --fix" }, "dependencies": { - "semver": "^7.3.5" + "semver": "^7.3.6" } }