Skip to content

Commit

Permalink
Merge branch 'main' into readme-links
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed May 17, 2024
2 parents 92c7427 + 776b2c9 commit e7d0349
Show file tree
Hide file tree
Showing 24 changed files with 7,087 additions and 6,568 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Issue: #

## What Changed

<!-- Insert a description below. Don't forget to run `yarn update-all` to update configuration files and their documentation! -->
<!-- Insert a description below. Don't forget to run `pnpm run update-all` to update configuration files and their documentation! -->

## Checklist

Check the ones applicable to your change:

- [ ] Ran `yarn update-all`
- [ ] Ran `pnpm run update-all`
- [ ] Tests are updated
- [ ] Documentation is updated

Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/linear-export.yml

This file was deleted.

11 changes: 4 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ jobs:
- name: Prepare repository
run: git fetch --unshallow --tags

- name: Use Node.js 14.x
uses: actions/setup-node@v1
- uses: pnpm/action-setup@v3
with:
node-version: 14.x

- name: Install dependencies
uses: bahmutov/npm-install@v1
version: 8
run_install: true

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn release
pnpm run release
12 changes: 5 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install dependencies
uses: bahmutov/npm-install@v1
- uses: pnpm/action-setup@v3
with:
version: 8
run_install: true

- name: Run tests
run: |
yarn test:ci
pnpm run test:ci
64 changes: 64 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,67 @@
# v0.8.0 (Fri Feb 16 2024)

#### 🚀 Enhancement

- upgrades and stuff [#150](https://github.com/storybookjs/eslint-plugin-storybook/pull/150) ([@ndelangen](https://github.com/ndelangen))

#### 🐛 Bug Fix

- fix release [#151](https://github.com/storybookjs/eslint-plugin-storybook/pull/151) ([@ndelangen](https://github.com/ndelangen))

#### Authors: 1

- Norbert de Langen ([@ndelangen](https://github.com/ndelangen))

---

# v0.7.0 (Fri Feb 16 2024)

#### 🚀 Enhancement

- Disable rule of hooks in stories files [#149](https://github.com/storybookjs/eslint-plugin-storybook/pull/149) ([@ndelangen](https://github.com/ndelangen))

#### Authors: 1

- Norbert de Langen ([@ndelangen](https://github.com/ndelangen))

---

# v0.6.15 (Sun Oct 08 2023)

#### 🐛 Bug Fix

- no-uninstalled-addons: support satisfies operator and default reexport [#139](https://github.com/storybookjs/eslint-plugin-storybook/pull/139) ([@hjoelh](https://github.com/hjoelh))

#### Authors: 1

- Joel ([@hjoelh](https://github.com/hjoelh))

---

# v0.6.14 (Wed Sep 20 2023)

#### 🐛 Bug Fix

- use-storybook-expect: allow storybook/test imports [#141](https://github.com/storybookjs/eslint-plugin-storybook/pull/141) ([@yannbf](https://github.com/yannbf))

#### Authors: 1

- Yann Braga ([@yannbf](https://github.com/yannbf))

---

# v0.6.13 (Thu Jul 20 2023)

#### ⚠️ Pushed to `main`

- Create CODEOWNERS ([@valentinpalkovic](https://github.com/valentinpalkovic))

#### Authors: 1

- Valentin Palkovic ([@valentinpalkovic](https://github.com/valentinpalkovic))

---

# v0.6.12 (Wed May 03 2023)

#### 🐛 Bug Fix
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @yannbf @kasperpeulen
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Table of Contents

- [1. About the Project](#about-the-project)
- [2. Getting Started](#getting-started)
- [2.1. Creating a new rule](#creating-a-new-rule)
- [2.1.1. Important metadata for a rule](#important-metadata-for-a-rule)
- [2.2. Testing rules](#testing-rules)
- [2.3. Updating configs or documentation](#updating-configs-or-documentation)
- [3. Useful resources](#useful-resources)
- [About the project](#about-the-project)
- [Getting started](#getting-started)
- [Creating a new rule](#creating-a-new-rule)
- [Important metadata for a rule](#important-metadata-for-a-rule)
- [Testing rules](#testing-rules)
- [Updating configs or documentation](#updating-configs-or-documentation)
- [Useful resources](#useful-resources)

# About the project

Expand All @@ -21,7 +21,7 @@ First of all, thank you so much for taking the time to contribute to this projec
Run the following command and answer the prompts:

```sh
yarn generate-rule
pnpm run generate-rule
```

This command will generate the rule file, tests as well as the documentation page.
Expand Down Expand Up @@ -56,7 +56,7 @@ module.exports = {
Run the following command for testing the rules:

```sh
yarn test --watch
pnpm run test --watch
```

If you want to run tests for a particular rule and skip the rest, you can do so like this:
Expand Down
5 changes: 4 additions & 1 deletion docs/rules/no-uninstalled-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ module.exports = {
rules: {
'storybook/no-uninstalled-addons': [
'error',
{ packageJsonLocation: './folder/package.json', ignore: ['custom-addon'] },
{
packageJsonLocation: './folder/package.json',
ignore: ['custom-addon'],
},
],
},
}
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/addon-interactions.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update it's content execute "yarn update-all"
* in order to update it's content execute "pnpm run update-all"
*/
export = {
plugins: ['storybook'],
overrides: [
{
files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'import/no-anonymous-default-export': 'off',
'storybook/await-interactions': 'error',
'storybook/context-in-play-function': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/csf-strict.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update it's content execute "yarn update-all"
* in order to update it's content execute "pnpm run update-all"
*/
export = {
extends: require.resolve('./csf'),
rules: {
'react-hooks/rules-of-hooks': 'off',
'import/no-anonymous-default-export': 'off',
'storybook/no-stories-of': 'error',
'storybook/no-title-property-in-meta': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/csf.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update it's content execute "yarn update-all"
* in order to update it's content execute "pnpm run update-all"
*/
export = {
plugins: ['storybook'],
overrides: [
{
files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'import/no-anonymous-default-export': 'off',
'storybook/csf-component': 'warn',
'storybook/default-exports': 'error',
Expand Down
3 changes: 2 additions & 1 deletion lib/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/*
* IMPORTANT!
* This file has been automatically generated,
* in order to update it's content execute "yarn update-all"
* in order to update it's content execute "pnpm run update-all"
*/
export = {
plugins: ['storybook'],
overrides: [
{
files: ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)', '*.story.@(ts|tsx|js|jsx|mjs|cjs)'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'import/no-anonymous-default-export': 'off',
'storybook/await-interactions': 'error',
'storybook/context-in-play-function': 'error',
Expand Down
33 changes: 16 additions & 17 deletions lib/rules/no-uninstalled-addons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
isVariableDeclaration,
} from '../utils/ast'
import { TSESTree } from '@typescript-eslint/utils'
import { getMetaObjectExpression } from '../utils'

//------------------------------------------------------------------------------
// Rule Definition
Expand Down Expand Up @@ -228,34 +229,32 @@ export = createStorybookRule({
}
}

function findAddonsPropAndReport(node: TSESTree.ObjectExpression) {
const addonsProp = node.properties.find(
(prop): prop is TSESTree.Property =>
isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons'
)

if (addonsProp?.value && isArrayExpression(addonsProp.value)) {
reportUninstalledAddons(addonsProp.value)
}
}

//----------------------------------------------------------------------
// Public
//----------------------------------------------------------------------

return {
AssignmentExpression: function (node) {
if (isObjectExpression(node.right)) {
const addonsProp = node.right.properties.find(
(prop): prop is TSESTree.Property =>
isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons'
)

if (addonsProp && addonsProp.value && isArrayExpression(addonsProp.value)) {
reportUninstalledAddons(addonsProp.value)
}
findAddonsPropAndReport(node.right)
}
},
ExportDefaultDeclaration: function (node) {
if (isObjectExpression(node.declaration)) {
const addonsProp = node.declaration.properties.find(
(prop): prop is TSESTree.Property =>
isProperty(prop) && isIdentifier(prop.key) && prop.key.name === 'addons'
)
const meta = getMetaObjectExpression(node, context)
if (!meta) return null

if (addonsProp && addonsProp.value && isArrayExpression(addonsProp.value)) {
reportUninstalledAddons(addonsProp.value)
}
}
findAddonsPropAndReport(meta)
},
ExportNamedDeclaration: function (node) {
const addonsProp =
Expand Down
5 changes: 4 additions & 1 deletion lib/rules/use-storybook-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export = createStorybookRule<TDefaultOptions, string>({
//----------------------------------------------------------------------

const isExpectFromStorybookImported = (node: TSESTree.ImportDeclaration) => {
const { value: packageName } = node.source
const usesExpectFromStorybook =
packageName === '@storybook/jest' || packageName === '@storybook/test'
return (
node.source.value === '@storybook/jest' &&
usesExpectFromStorybook &&
node.specifiers.find((spec) => isImportSpecifier(spec) && spec.imported.name === 'expect')
)
}
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ export const getDescriptor = (
switch (type) {
case 'ArrayExpression':
return property.value.elements.map((t) => {
if (t === null) {
throw new Error(`Unexpected descriptor element: null`)
}
if (!['StringLiteral', 'Literal'].includes(t.type)) {
throw new Error(`Unexpected descriptor element: ${t.type}`)
}
Expand Down
Loading

0 comments on commit e7d0349

Please sign in to comment.