From 06808b3599fead320827f1f7de3b37e89e63f37b Mon Sep 17 00:00:00 2001 From: Zou Guangxian Date: Tue, 24 Oct 2023 21:31:01 +0800 Subject: [PATCH 1/2] feat: support require the package with fullname supports require.resolve(package) in extends field --- lib/config/config-file.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/config/config-file.js b/lib/config/config-file.js index f101d8ff..b3aace6c 100644 --- a/lib/config/config-file.js +++ b/lib/config/config-file.js @@ -64,8 +64,13 @@ const loadConfig = (configFile) => { return searchedFor.config || createEmptyConfig() } -const configGetter = (path) => - path.startsWith('solhint:') ? getSolhintCoreConfig(path) : require(`solhint-config-${path}`) +const isAbsolute = path.isAbsolute +const configGetter = (path) => { + if (isAbsolute(path)) { + return require(path) + } + return path.startsWith('solhint:') ? getSolhintCoreConfig(path) : require(`solhint-config-${path}`) +} const applyExtends = (config, getter = configGetter) => { if (!config.extends) { From cdcccee9615effdcda87d8613b7237cf8122cbb6 Mon Sep 17 00:00:00 2001 From: Zou Guangxian Date: Fri, 27 Oct 2023 23:36:17 +0800 Subject: [PATCH 2/2] fix: eslint issues --- lib/config/config-file.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/config/config-file.js b/lib/config/config-file.js index b3aace6c..3ae3c1d1 100644 --- a/lib/config/config-file.js +++ b/lib/config/config-file.js @@ -1,4 +1,5 @@ const fs = require('fs') +const path = require('path') const _ = require('lodash') const { cosmiconfigSync } = require('cosmiconfig') const { ConfigMissingError } = require('../common/errors') @@ -69,7 +70,9 @@ const configGetter = (path) => { if (isAbsolute(path)) { return require(path) } - return path.startsWith('solhint:') ? getSolhintCoreConfig(path) : require(`solhint-config-${path}`) + return path.startsWith('solhint:') + ? getSolhintCoreConfig(path) + : require(`solhint-config-${path}`) } const applyExtends = (config, getter = configGetter) => {