diff --git a/package.json b/package.json index 6a219839..63945c1e 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "lodash.difference": "4.5.0", "mocha": "10.0.0", "npm-check": "6.0.1", + "plugin-name-to-package-name": "0.1.1", "robo-config": "4.0.5", "smart-fs": "3.0.1" }, diff --git a/src/subtasks/eslint.js b/src/subtasks/eslint.js index 8a45dc64..7b95b47a 100644 --- a/src/subtasks/eslint.js +++ b/src/subtasks/eslint.js @@ -1,6 +1,7 @@ import fs from 'smart-fs'; import path from 'path'; import { ESLint } from 'eslint'; +import { transform } from 'plugin-name-to-package-name'; export default (logger, dir, { files = [], fix = false } = {}) => (async () => { if (files.length === 0) { @@ -10,10 +11,7 @@ export default (logger, dir, { files = [], fix = false } = {}) => (async () => { const configFile = path.join(dir, '.eslintrc.json'); const config = fs.existsSync(configFile) ? fs.smartRead(configFile) : {}; const plugins = Object.fromEntries(await Promise.all((config.plugins || []) - .map((p) => { - const [org, name] = p.includes('/') ? p.split('/') : ['', p]; - return `${org}${org === '' ? '' : '/'}eslint-plugin-${name}`; - }) + .map((p) => transform(p, 'eslint-plugin')) .map((p) => import(p).then(({ default: d }) => [p, d])))); const eslint = new ESLint({ diff --git a/yarn.lock b/yarn.lock index e0ea5ad5..bcf89fca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3253,6 +3253,11 @@ please-upgrade-node@^3.2.0: dependencies: semver-compare "^1.0.0" +plugin-name-to-package-name@0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/plugin-name-to-package-name/-/plugin-name-to-package-name-0.1.1.tgz#14ec03fc42a88b1aa5edb9c1132589bddfc35f57" + integrity sha512-TrfIKmAQzAvATMavKb+I5kNv24jmPBrQ71VPGc7RC8/n5FtRXr0ZRZ1GxVfcJw06/VSM/zAGyI5CKcxWMSwT6A== + postcss@^8.1.10: version "8.4.16" resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c"