Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-storybook

Package Overview
Dependencies
Maintainers
2
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-storybook - npm Package Compare versions

Comparing version 0.6.8 to 0.6.12

57

CHANGELOG.md

@@ -0,1 +1,58 @@

# v0.6.12 (Wed May 03 2023)
#### 🐛 Bug Fix
- feat: allow ignore option in no-uninstalled-addons [#129](https://github.com/storybookjs/eslint-plugin-storybook/pull/129) ([@mandarini](https://github.com/mandarini) [@yannbf](https://github.com/yannbf))
#### 📝 Documentation
- docs: add async [#121](https://github.com/storybookjs/eslint-plugin-storybook/pull/121) ([@tyankatsu0105](https://github.com/tyankatsu0105))
#### Authors: 3
- Katerina Skroumpelou ([@mandarini](https://github.com/mandarini))
- tyankatsu ([@tyankatsu0105](https://github.com/tyankatsu0105))
- Yann Braga ([@yannbf](https://github.com/yannbf))
---
# v0.6.11 (Tue Feb 21 2023)
#### 🐛 Bug Fix
- Make context-in-play-function aware of context variable name [#120](https://github.com/storybookjs/eslint-plugin-storybook/pull/120) ([@beaussan](https://github.com/beaussan))
- improve rule template [#119](https://github.com/storybookjs/eslint-plugin-storybook/pull/119) ([@yannbf](https://github.com/yannbf))
#### Authors: 2
- Nicolas Beaussart ([@beaussan](https://github.com/beaussan))
- Yann Braga ([@yannbf](https://github.com/yannbf))
---
# v0.6.10 (Tue Jan 10 2023)
#### 🐛 Bug Fix
- chore: fix ESLint and TypeScript issues [#113](https://github.com/storybookjs/eslint-plugin-storybook/pull/113) ([@Dschungelabenteuer](https://github.com/Dschungelabenteuer) [@yannbf](https://github.com/yannbf))
#### Authors: 2
- n028 ([@Dschungelabenteuer](https://github.com/Dschungelabenteuer))
- Yann Braga ([@yannbf](https://github.com/yannbf))
---
# v0.6.9 (Tue Jan 10 2023)
#### 🐛 Bug Fix
- fix(no-uninstalled-addons) Support Windows paths [#112](https://github.com/storybookjs/eslint-plugin-storybook/pull/112) ([@Dschungelabenteuer](https://github.com/Dschungelabenteuer))
#### Authors: 1
- n028 ([@Dschungelabenteuer](https://github.com/Dschungelabenteuer))
---
# v0.6.8 (Mon Dec 05 2022)

@@ -2,0 +59,0 @@

2

dist/rules/await-interactions.js

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

let isImportedFromStorybook = true;
let invocationsThatShouldBeAwaited = [];
const invocationsThatShouldBeAwaited = [];
return {

@@ -109,0 +109,0 @@ ImportDeclaration(node) {

@@ -45,2 +45,29 @@ "use strict";

};
const getParentParameterName = (node) => {
if (!(0, ast_1.isArrowFunctionExpression)(node)) {
if (!node.parent) {
return undefined;
}
return getParentParameterName(node.parent);
}
// No parameter found
if (node.params.length === 0) {
return undefined;
}
if (node.params.length >= 1) {
const param = node.params[0];
if ((0, ast_1.isIdentifier)(param)) {
return param.name;
}
if ((0, ast_1.isObjectPattern)(param)) {
const restElement = param.properties.find(ast_1.isRestElement);
if (!restElement || !(0, ast_1.isIdentifier)(restElement.argument)) {
// No rest element found
return undefined;
}
return restElement.argument.name;
}
}
return undefined;
};
// Expression passing an argument called context OR spreading a variable called context

@@ -52,5 +79,9 @@ const isNotPassingContextCorrectly = (expr) => {

}
const contextVariableName = getParentParameterName(expr);
if (!contextVariableName) {
return true;
}
if (expr.arguments.length === 1 &&
(0, ast_1.isIdentifier)(firstExpressionArgument) &&
firstExpressionArgument.name === 'context') {
firstExpressionArgument.name === contextVariableName) {
return false;

@@ -60,3 +91,5 @@ }

firstExpressionArgument.properties.some((prop) => {
return ((0, ast_1.isSpreadElement)(prop) && (0, ast_1.isIdentifier)(prop.argument) && prop.argument.name === 'context');
return ((0, ast_1.isSpreadElement)(prop) &&
(0, ast_1.isIdentifier)(prop.argument) &&
prop.argument.name === contextVariableName);
})) {

@@ -70,3 +103,3 @@ return false;

//----------------------------------------------------------------------
let invocationsWithoutProperContext = [];
const invocationsWithoutProperContext = [];
return {

@@ -73,0 +106,0 @@ CallExpression(node) {

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

const ruleProperties = ['title', 'args'];
let dynamicProperties = [];
const dynamicProperties = [];
const metaNodes = meta.properties.filter((prop) => 'key' in prop && 'name' in prop.key && ruleProperties.includes(prop.key.name));

@@ -65,0 +65,0 @@ metaNodes.forEach((metaNode) => {

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

name: 'no-uninstalled-addons',
defaultOptions: [],
defaultOptions: [
{
packageJsonLocation: '',
ignore: [],
},
],
meta: {

@@ -36,11 +41,20 @@ type: 'problem',

},
ignore: {
type: 'array',
items: {
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;
}, '');
const { packageJsonLocation, ignore } = context.options.reduce((acc, val) => {
return {
packageJsonLocation: val['packageJsonLocation'] || acc.packageJsonLocation,
ignore: val['ignore'] || acc.ignore,
};
}, { packageJsonLocation: '', ignore: [] });
//----------------------------------------------------------------------

@@ -78,3 +92,3 @@ // Helpers

.filter(filterLocalAddons)
.filter((addon) => !isAddonInstalled(addon, installedSbAddons))
.filter((addon) => !isAddonInstalled(addon, installedSbAddons) && !ignore.includes(addon))
.map((addon) => ({ name: addon }));

@@ -141,4 +155,4 @@ return result.length ? result : false;

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)}`;
const rootDir = process.cwd().split(path_1.sep).pop();
const packageJsonPath = `${rootDir}${path_1.sep}${(0, path_1.relative)(process.cwd(), packageJsonLocation)}`;
elemsWithErrors.forEach((elem) => {

@@ -145,0 +159,0 @@ context.report({

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

for (let i = 0; i < referenceCount; i++) {
const ref = variable.references[i];
const ref = variable === null || variable === void 0 ? void 0 : variable.references[i];
if (ref && !ref.init) {

@@ -89,3 +89,3 @@ yield fixer.replaceTextRange(ref.identifier.range, pascal);

let nonStoryExportsConfig;
let namedExports = [];
const namedExports = [];
let hasStoriesOfImport = false;

@@ -107,3 +107,5 @@ return {

}
catch (err) { }
catch (err) {
//
}
}

@@ -110,0 +112,0 @@ },

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

let meta;
let namedExports = [];
const namedExports = [];
return {

@@ -56,3 +56,5 @@ ImportSpecifier(node) {

}
catch (err) { }
catch (err) {
//
}
}

@@ -59,0 +61,0 @@ },

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

let isImportingFromStorybookExpect = false;
let expectInvocations = [];
const expectInvocations = [];
return {

@@ -43,0 +43,0 @@ ImportDeclaration(node) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// const docs: StorybookRuleMetaDocs<any> = {
// recommended: true,
// Comment out for testing purposes:
// const docs: StorybookRuleMetaDocs = {
// description: 'bla',
// recommended: 'error',
// }
// const meta: StorybookRuleMeta<'someId', any> = {
// const meta: StorybookRuleMeta<'someId'> = {
// messages: {

@@ -10,0 +10,0 @@ // someId: 'yea',

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMetaProperty = exports.isTSNonNullExpression = exports.isTSSatisfiesExpression = exports.isTSAsExpression = exports.isTSInterfaceDeclaration = exports.isTSTypeAliasDeclaration = exports.isProgram = exports.isFunctionExpression = exports.isFunctionDeclaration = exports.isReturnStatement = exports.isSpreadElement = exports.isProperty = exports.isObjectPattern = exports.isObjectExpression = exports.isNewExpression = exports.isMemberExpression = exports.isLiteral = exports.isJSXAttribute = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isSequenceExpression = exports.isAssignmentExpression = exports.isVariableDeclaration = exports.isExpressionStatement = exports.isCallExpression = exports.isBlockStatement = exports.isArrowFunctionExpression = exports.isArrayExpression = exports.isVariableDeclarator = exports.isIdentifier = exports.isAwaitExpression = exports.ASTUtils = void 0;
exports.isMetaProperty = exports.isTSNonNullExpression = exports.isTSSatisfiesExpression = exports.isTSAsExpression = exports.isTSInterfaceDeclaration = exports.isTSTypeAliasDeclaration = exports.isProgram = exports.isFunctionExpression = exports.isFunctionDeclaration = exports.isReturnStatement = exports.isRestElement = exports.isSpreadElement = exports.isProperty = exports.isObjectPattern = exports.isObjectExpression = exports.isNewExpression = exports.isMemberExpression = exports.isLiteral = exports.isJSXAttribute = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isSequenceExpression = exports.isAssignmentExpression = exports.isVariableDeclaration = exports.isExpressionStatement = exports.isCallExpression = exports.isBlockStatement = exports.isArrowFunctionExpression = exports.isArrayExpression = exports.isVariableDeclarator = exports.isIdentifier = exports.isAwaitExpression = exports.ASTUtils = void 0;
const utils_1 = require("@typescript-eslint/utils");

@@ -31,2 +31,3 @@ var utils_2 = require("@typescript-eslint/utils");

exports.isSpreadElement = isNodeOfType(utils_1.AST_NODE_TYPES.SpreadElement);
exports.isRestElement = isNodeOfType(utils_1.AST_NODE_TYPES.RestElement);
exports.isReturnStatement = isNodeOfType(utils_1.AST_NODE_TYPES.ReturnStatement);

@@ -33,0 +34,0 @@ exports.isFunctionDeclaration = isNodeOfType(utils_1.AST_NODE_TYPES.FunctionDeclaration);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllNamedExports = exports.isValidStoryExport = exports.getDescriptor = exports.getMetaObjectExpression = exports.docsUrl = void 0;
/* eslint-disable no-fallthrough */
const csf_1 = require("@storybook/csf");

@@ -37,10 +38,9 @@ const utils_1 = require("@typescript-eslint/utils");

}
// @ts-ignore
// @ts-expect-error TODO: t should be only StringLiteral or Literal, and the type is not resolving correctly
return t.value;
});
case 'Literal':
// TODO: Investigation needed. Type systems says, that "RegExpLiteral" does not exist
// @ts-ignore
// @ts-expect-error TODO: Investigation needed. Type systems says, that "RegExpLiteral" does not exist
case 'RegExpLiteral':
// @ts-ignore
// @ts-expect-error TODO: investigation needed
return property.value.value;

@@ -47,0 +47,0 @@ default:

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

@@ -59,2 +59,3 @@ "keywords": [

"@types/requireindex": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.3.0",

@@ -61,0 +62,0 @@ "auto": "^10.32.2",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc