@clark/eslint-util-get-package
v2.2.0
Published
Finds the `package.json` a source file belongs to
Downloads
693
Readme
@clark/eslint-util-get-package
Finds the
package.json
a source file belongs to.
import getPackage from "@clark/eslint-util-get-package";
export const rules = {
"some-rule": {
create(context) {
const fileName = context.getFilename();
const packageJSON = getPackage(fileName);
if (!packageJSON)
throw new Error(
`Could not find a 'package.json' that '${fileName}' belongs to.`
);
console.log(`'${fileName}' belongs to ${packageJSON.name}.`);
// ...
},
},
};