Expected behavior
imports-as-dependencies supports types defined in the exports property.
Actual behavior
imports-as-dependencies reports: import points to package which is not found in dependencies. Because the rule only looks at the types and typings properties. importsAsDependencies.js#L106
Files
package.json
{
"name": "testcase",
"dependencies": {
"eslint": "8.42.0",
"eslint-plugin-jsdoc": "46.2.4",
"playwright": "1.34.3"
},
"eslintConfig": {
"plugins": [
"jsdoc"
],
"rules": {
"jsdoc/imports-as-dependencies": "error"
}
}
}
index.js
/**
* @type {import("playwright")}
*/
var playwright;
Environment
- Node version: 18.16.0
- ESLint version 8.42.0
eslint-plugin-jsdoc version: 46.2.4
Additional info
There's a similar problem with ESLint rules checking imports, as they only look at the main property:
Expected behavior
imports-as-dependenciessupports types defined in theexportsproperty.Actual behavior
imports-as-dependenciesreports: import points to package which is not found in dependencies. Because the rule only looks at thetypesandtypingsproperties.importsAsDependencies.js#L106Files
package.json{ "name": "testcase", "dependencies": { "eslint": "8.42.0", "eslint-plugin-jsdoc": "46.2.4", "playwright": "1.34.3" }, "eslintConfig": { "plugins": [ "jsdoc" ], "rules": { "jsdoc/imports-as-dependencies": "error" } } }index.jsEnvironment
eslint-plugin-jsdocversion: 46.2.4Additional info
There's a similar problem with ESLint rules checking imports, as they only look at the
mainproperty:no-missing-importsdoes not support "exports" in package.json mysticatea/eslint-plugin-node#255no-unresolvedis not aware ofexportsdefinition inpackage.jsonimport-js/eslint-plugin-import#1810import/no-unresolvedraise false positive when there is nomainfield in thepackage.jsonimport-js/eslint-plugin-import#2132