Socket
Socket
Sign inDemoInstall

eslint-plugin-storybook

Package Overview
Dependencies
Maintainers
2
Versions
93
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.0.1-alpha.6 to 0.0.1-alpha.7

17

dist/rules/await-interactions.js

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

module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'await-interactions',
defaultOptions: [],

@@ -46,4 +46,3 @@ meta: {

};
if ((0, ast_1.isCallExpression)(expr) &&
(0, ast_1.isMemberExpression)(expr.callee) &&
if ((0, ast_1.isMemberExpression)(expr.callee) &&
(0, ast_1.isIdentifier)(expr.callee.object) &&

@@ -53,4 +52,3 @@ shouldAwait(expr.callee.object.name)) {

}
if ((0, ast_1.isCallExpression)(expr) &&
(0, ast_1.isMemberExpression)(expr.callee) &&
if ((0, ast_1.isMemberExpression)(expr.callee) &&
(0, ast_1.isIdentifier)(expr.callee.property) &&

@@ -60,2 +58,5 @@ shouldAwait(expr.callee.property.name)) {

}
if ((0, ast_1.isIdentifier)(expr.callee) && shouldAwait(expr.callee.name)) {
return expr.callee;
}
return null;

@@ -86,5 +87,5 @@ };

},
// fix: function (fixer) {
// return fixer.insertTextBefore(node, 'await ')
// },
fix: function (fixer) {
return fixer.insertTextBefore(node, 'await ');
},
suggest: [

@@ -91,0 +92,0 @@ {

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

*/
const utils_1 = require("../utils");
const constants_1 = require("../utils/constants");
const create_storybook_rule_1 = require("../utils/create-storybook-rule");
module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'csf-component',
defaultOptions: [],

@@ -34,11 +35,9 @@ meta: {

return {
ExportDefaultDeclaration: function (node) {
// Typescript 'TSAsExpression' has properties under declaration.expression
const metaProperties = node.declaration.properties ||
(node.declaration.expression && node.declaration.expression.properties);
if (!metaProperties) {
return;
ExportDefaultDeclaration(node) {
const meta = (0, utils_1.getMetaObjectExpression)(node, context);
if (!meta) {
return null;
}
const component = metaProperties.find((prop) => prop.key.name === 'component');
if (!component) {
const componentProperty = meta.properties.find((property) => property.key.name === 'component');
if (!componentProperty) {
context.report({

@@ -45,0 +44,0 @@ node,

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

module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'default-export',
defaultOptions: [],

@@ -12,0 +12,0 @@ meta: {

@@ -6,6 +6,8 @@ "use strict";

*/
const utils_1 = require("../utils");
const ast_1 = require("../utils/ast");
const constants_1 = require("../utils/constants");
const create_storybook_rule_1 = require("../utils/create-storybook-rule");
module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'hierarchy-separator',
defaultOptions: [],

@@ -29,13 +31,12 @@ meta: {

ExportDefaultDeclaration: function (node) {
// Typescript 'TSAsExpression' has properties under declaration.expression
const metaProperties = node.declaration.properties ||
(node.declaration.expression && node.declaration.expression.properties);
if (!metaProperties) {
return;
const meta = (0, utils_1.getMetaObjectExpression)(node, context);
if (!meta) {
return null;
}
const titleNode = metaProperties.find((prop) => prop.key.name === 'title');
// @ts-expect-error ts-migrate(2367) FIXME: This condition will always return 'false' since th... Remove this comment to see the full error message
if (!titleNode || !titleNode.value.type === 'Literal') {
const titleNode = meta.properties.find((prop) => prop.key.name === 'title');
//@ts-ignore
if (!titleNode || !(0, ast_1.isLiteral)(titleNode.value)) {
return;
}
//@ts-ignore
const metaTitle = titleNode.value.raw || '';

@@ -49,3 +50,5 @@ if (metaTitle.includes('|') || metaTitle.includes('.')) {

fix: function (fixer) {
return fixer.replaceTextRange(titleNode.value.range, metaTitle.replace(/\||\./g, '/'));
return fixer.replaceTextRange(
//@ts-ignore
titleNode.value.range, metaTitle.replace(/\||\./g, '/'));
},

@@ -56,3 +59,5 @@ suggest: [

fix: function (fixer) {
return fixer.replaceTextRange(titleNode.value.range, metaTitle.replace(/\||\./g, '/'));
return fixer.replaceTextRange(
//@ts-ignore
titleNode.value.range, metaTitle.replace(/\||\./g, '/'));
},

@@ -59,0 +64,0 @@ },

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

*/
const utils_1 = require("../utils");
const constants_1 = require("../utils/constants");
const create_storybook_rule_1 = require("../utils/create-storybook-rule");
module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'meta-inline-properties',
defaultOptions: [{ csfVersion: 3 }],

@@ -54,11 +55,9 @@ meta: {

ExportDefaultDeclaration(node) {
// Typescript 'TSAsExpression' has properties under declaration.expression
const metaProperties = node.declaration.properties ||
(node.declaration.expression && node.declaration.expression.properties);
if (!metaProperties) {
return;
const meta = (0, utils_1.getMetaObjectExpression)(node, context);
if (!meta) {
return null;
}
const ruleProperties = ['title', 'args'];
let dynamicProperties = [];
const metaNodes = metaProperties.filter((prop) =>
const metaNodes = meta.properties.filter((prop) =>
//@ts-ignore

@@ -65,0 +64,0 @@ ruleProperties.includes(prop.key.name));

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

module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'no-redundant-story-name',
defaultOptions: [],

@@ -13,0 +13,0 @@ meta: {

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

module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'no-stories-of',
defaultOptions: [],

@@ -12,0 +12,0 @@ meta: {

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

*/
const utils_1 = require("../utils");
const constants_1 = require("../utils/constants");
const create_storybook_rule_1 = require("../utils/create-storybook-rule");
module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'no-title-property-in-meta',
defaultOptions: [],

@@ -30,9 +31,7 @@ meta: {

ExportDefaultDeclaration: function (node) {
// Typescript 'TSAsExpression' has properties under declaration.expression
const metaProperties = node.declaration.properties ||
(node.declaration.expression && node.declaration.expression.properties);
if (!metaProperties) {
return;
const meta = (0, utils_1.getMetaObjectExpression)(node, context);
if (!meta) {
return null;
}
const titleNode = metaProperties.find((prop) => prop.key.name === 'title');
const titleNode = meta.properties.find((prop) => prop.key.name === 'title');
if (titleNode) {

@@ -39,0 +38,0 @@ context.report({

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

module.exports = (0, create_storybook_rule_1.createStorybookRule)({
name: '',
name: 'prefer-pascal-case',
defaultOptions: [],

@@ -12,0 +12,0 @@ meta: {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isProgram = exports.isFunctionExpression = exports.isReturnStatement = 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.isTSAsExpression = exports.isProgram = exports.isFunctionExpression = exports.isReturnStatement = 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 experimental_utils_1 = require("@typescript-eslint/experimental-utils");

@@ -33,1 +33,2 @@ var experimental_utils_2 = require("@typescript-eslint/experimental-utils");

exports.isProgram = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Program);
exports.isTSAsExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSAsExpression);
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPlayFunction = exports.docsUrl = void 0;
exports.getMetaObjectExpression = exports.isPlayFunction = exports.docsUrl = void 0;
const ast_utils_1 = require("@typescript-eslint/experimental-utils/dist/ast-utils");
const ast_1 = require("./ast");
const docsUrl = (ruleName) => `https://github.com/storybookjs/eslint-plugin-storybook/blob/main/docs/rules/${ruleName}.md`;

@@ -11,1 +13,16 @@ exports.docsUrl = docsUrl;

exports.isPlayFunction = isPlayFunction;
const getMetaObjectExpression = (node, context) => {
let meta = node.declaration;
if ((0, ast_1.isIdentifier)(meta)) {
const variable = (0, ast_utils_1.findVariable)(context.getScope(), meta.name);
const decl = variable && variable.defs.find((def) => (0, ast_1.isVariableDeclarator)(def.node));
if (decl && (0, ast_1.isVariableDeclarator)(decl.node)) {
meta = decl.node.init;
}
}
if ((0, ast_1.isTSAsExpression)(meta)) {
meta = meta.expression;
}
return (0, ast_1.isObjectExpression)(meta) ? meta : null;
};
exports.getMetaObjectExpression = getMetaObjectExpression;
{
"name": "eslint-plugin-storybook",
"version": "0.0.1-alpha.6",
"version": "0.0.1-alpha.7",
"description": "Best practice rules for Storybook",

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

@@ -108,3 +108,3 @@ <p align="center">

| ------------------------------------------------------------------------------------------ | ------------------------------------------------- | --- | ------------------------------- |
| [`storybook/await-interactions`](./docs/rules/await-interactions.md) | Interactions should be awaited | | addon-interactions, recommended |
| [`storybook/await-interactions`](./docs/rules/await-interactions.md) | Interactions should be awaited | 🔧 | addon-interactions, recommended |
| [`storybook/csf-component`](./docs/rules/csf-component.md) | The component property should be set | | csf |

@@ -111,0 +111,0 @@ | [`storybook/default-exports`](./docs/rules/default-exports.md) | Story files should have a default export | | csf, recommended |

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