Socket
Socket
Sign inDemoInstall

eslint-plugin-storybook

Package Overview
Dependencies
130
Maintainers
2
Versions
91
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.1 to 0.6.2

21

CHANGELOG.md

@@ -0,1 +1,22 @@

# v0.6.2 (Tue Aug 02 2022)
### Release Notes
#### feat(no-uninstalled-addons): add option for a custom package.json location ([#102](https://github.com/storybookjs/eslint-plugin-storybook/pull/102))
#### feat(no-uninstalled-addons): add option for a custom package.json location ([#102](https://github.com/storybookjs/eslint-plugin-storybook/pull/102))
---
#### 🐛 Bug Fix
- feat(no-uninstalled-addons): add option for a custom package.json location [#102](https://github.com/storybookjs/eslint-plugin-storybook/pull/102) ([@andrelas1](https://github.com/andrelas1) [@yannbf](https://github.com/yannbf))
#### Authors: 2
- Andre Luis Araujo Santos ([@andrelas1](https://github.com/andrelas1))
- Yann Braga ([@yannbf](https://github.com/yannbf))
---
# v0.6.1 (Tue Jul 12 2022)

@@ -2,0 +23,0 @@

2

dist/configs/addon-interactions.js

@@ -16,3 +16,3 @@ "use strict";

{
files: ['main.@(js|cjs|mjs|ts)'],
files: ['.storybook/main.@(js|cjs|mjs|ts)'],
rules: {

@@ -19,0 +19,0 @@ 'storybook/no-uninstalled-addons': 'error',

@@ -17,3 +17,3 @@ "use strict";

{
files: ['main.@(js|cjs|mjs|ts)'],
files: ['.storybook/main.@(js|cjs|mjs|ts)'],
rules: {

@@ -20,0 +20,0 @@ 'storybook/no-uninstalled-addons': 'error',

@@ -21,3 +21,3 @@ "use strict";

{
files: ['main.@(js|cjs|mjs|ts)'],
files: ['.storybook/main.@(js|cjs|mjs|ts)'],
rules: {

@@ -24,0 +24,0 @@ 'storybook/no-uninstalled-addons': 'error',

@@ -6,3 +6,7 @@ "use strict";

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const fs_1 = require("fs");
const ts_dedent_1 = __importDefault(require("ts-dedent"));
const path_1 = require("path");

@@ -23,8 +27,20 @@ const create_storybook_rule_1 = require("../utils/create-storybook-rule");

messages: {
addonIsNotInstalled: `The {{ addonName }} is not installed. Did you forget to install it?`,
addonIsNotInstalled: `The {{ addonName }} is not installed in {{packageJsonPath}}. Did you forget to install it or is your package.json in a different location?`,
},
schema: [], // Add a schema if the rule has options. Otherwise remove this
schema: [
{
type: 'object',
properties: {
packageJsonLocation: {
type: 'string',
},
},
},
], // Add a schema if the rule has options. Otherwise remove this
},
create(context) {
// variables should be defined here
const packageJsonLocation = context.options.reduce((acc, val) => {
return val['packageJsonLocation'] || acc;
}, '');
//----------------------------------------------------------------------

@@ -70,3 +86,6 @@ // Helpers

catch (e) {
throw new Error('Could not fetch package.json - it is probably not in the same directory as the .storybook folder');
throw new Error((0, ts_dedent_1.default) `The provided path in your eslintrc.json - ${path} is not a valid path to a package.json file or your package.json file is not in the same folder as ESLint is running from.
Read more at: https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/no-uninstalled-addons.md
`);
}

@@ -100,15 +119,10 @@ return packageJson;

function reportUninstalledAddons(addonsProp) {
// when this is running for .storybook/main.js, we get the path to the folder which contains the package.json of the
// project. This will be handy for monorepos that may be running ESLint in a node process in another folder.
const projectRoot = context.getPhysicalFilename
? (0, path_1.resolve)(context.getPhysicalFilename(), '../../')
: './';
const packageJsonPath = (0, path_1.resolve)(packageJsonLocation || `./package.json`);
let packageJsonObject;
try {
packageJsonObject = getPackageJson(`${projectRoot}/package.json`);
packageJsonObject = getPackageJson(packageJsonPath);
}
catch (e) {
// if we cannot find the package.json, we cannot check if the addons are installed
console.error(e);
return;
throw new Error(e);
}

@@ -120,2 +134,4 @@ const depsAndDevDeps = mergeDepsWithDevDeps(packageJsonObject);

const elemsWithErrors = listOfAddonElements.filter((elem) => !!result.find((addon) => addon.name === elem.value));
const rootDir = process.cwd().split('/').pop();
const packageJsonPath = `${rootDir}/${(0, path_1.relative)(process.cwd(), packageJsonLocation)}`;
elemsWithErrors.forEach((elem) => {

@@ -125,3 +141,6 @@ context.report({

messageId: 'addonIsNotInstalled',
data: { addonName: elem.value },
data: {
addonName: elem.value,
packageJsonPath,
},
});

@@ -128,0 +147,0 @@ });

{
"name": "eslint-plugin-storybook",
"version": "0.6.1",
"version": "0.6.2",
"description": "Best practice rules for Storybook",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc