eslint-plugin-storybook
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "eslint-plugin-storybook", | ||
"version": "0.1.1", | ||
"description": "ESlint rules for Storybook Best Practices ", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/rafaelrozon/eslint-plugin-storybook" | ||
}, | ||
"version": "0.2.0", | ||
"description": "Best practice rules for Storybook", | ||
"keywords": [ | ||
@@ -13,21 +9,90 @@ "eslint", | ||
"eslint-plugin", | ||
"storybook", | ||
"bestPractices" | ||
"storybook" | ||
], | ||
"author": "Rafael Rozon", | ||
"main": "lib/index.js", | ||
"author": "yannbf@gmail.com", | ||
"contributors": [ | ||
{ | ||
"name": "Rafael Rozon", | ||
"email": "rafaelrozon.developer@gmail.com" | ||
} | ||
], | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist/**/*", | ||
"README.md" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/storybookjs/eslint-plugin-storybook" | ||
}, | ||
"homepage": "https://github.com/storybookjs/eslint-plugin-storybook#readme", | ||
"bugs": { | ||
"url": "https://github.com/storybookjs/eslint-plugin-storybook/issues" | ||
}, | ||
"scripts": { | ||
"test": "mocha tests --recursive" | ||
"lint": "eslint --fix .", | ||
"migrate": "ts-migrate-full", | ||
"prebuild": "rimraf dist", | ||
"build": "tsc", | ||
"start": "tsc --watch", | ||
"test": "jest", | ||
"test:ci": "jest --ci", | ||
"generate-rule": "ts-node ./tools/generate-rule", | ||
"update-configs": "ts-node ./tools/update-configs", | ||
"update-docs": "ts-node ./tools/update-rules-list", | ||
"update-all": "yarn update-configs && yarn update-docs", | ||
"prepare": "husky install", | ||
"prettier": "prettier --write .", | ||
"release": "yarn build && auto shipit" | ||
}, | ||
"dependencies": { | ||
"requireindex": "~1.1.0" | ||
"@typescript-eslint/experimental-utils": "^5.3.0", | ||
"requireindex": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"@auto-it/released": "^10.32.2", | ||
"@types/eslint": "^7.28.2", | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^16.11.6", | ||
"@typescript-eslint/parser": "^5.3.0", | ||
"auto": "^10.32.2", | ||
"eslint": "^7.1.0", | ||
"mocha": "^7.2.0" | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-eslint-plugin": "^3.2.0", | ||
"eslint-plugin-node": "^11.0.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": ">=6", | ||
"jest": "^27.3.1", | ||
"lint-staged": ">=10", | ||
"prettier": "^2.4.0", | ||
"prompts": "^2.4.2", | ||
"rimraf": "^3.0.2", | ||
"ts-dedent": "^2.2.0", | ||
"ts-jest": "^27.0.7", | ||
"ts-migrate": "^0.1.26", | ||
"ts-node": "^10.4.0", | ||
"tsc": "^2.0.3", | ||
"typescript": "^4.4.4" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": "12.x || 14.x || >= 16" | ||
}, | ||
"license": "ISC" | ||
"peerDependencies": { | ||
"eslint": ">=6" | ||
}, | ||
"license": "MIT", | ||
"lint-staged": { | ||
"*.js": "eslint --cache --fix", | ||
"*.{js,css,md}": "prettier --write" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"auto": { | ||
"plugins": [ | ||
"npm", | ||
"released" | ||
], | ||
"onlyPublishWithReleaseLabel": true | ||
} | ||
} |
108
README.md
@@ -0,20 +1,47 @@ | ||
<p align="center"> | ||
<a href="https://storybook.js.org/"> | ||
<img src="https://user-images.githubusercontent.com/321738/63501763-88dbf600-c4cc-11e9-96cd-94adadc2fd72.png" alt="Storybook" width="400" /> | ||
</a> | ||
</p> | ||
<p align="center">Build bulletproof UI components faster</p> | ||
<br/> | ||
<p align="center"> | ||
<a href="https://discord.gg/storybook"> | ||
<img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" /> | ||
</a> | ||
<a href="https://storybook.js.org/community/"> | ||
<img src="https://img.shields.io/badge/community-join-4BC424.svg" alt="Storybook Community" /> | ||
</a> | ||
<a href="#backers"> | ||
<img src="https://opencollective.com/storybook/backers/badge.svg" alt="Backers on Open Collective" /> | ||
</a> | ||
<a href="#sponsors"> | ||
<img src="https://opencollective.com/storybook/sponsors/badge.svg" alt="Sponsors on Open Collective" /> | ||
</a> | ||
<a href="https://twitter.com/intent/follow?screen_name=storybookjs"> | ||
<img src="https://badgen.net/twitter/follow/storybookjs?icon=twitter&label=%40storybookjs" alt="Official Twitter Handle" /> | ||
</a> | ||
</p> | ||
# eslint-plugin-storybook | ||
Eslint rules for Storybook Best Practices | ||
Best practice rules for Storybook | ||
## Installation | ||
You'll first need to install [ESLint](http://eslint.org): | ||
You'll first need to install [ESLint](https://eslint.org/): | ||
```sh | ||
npm i eslint --save-dev | ||
``` | ||
$ npm i eslint --save-dev | ||
``` | ||
Next, install `eslint-plugin-storybook`: | ||
```sh | ||
npm install eslint-plugin-storybook --save-dev | ||
``` | ||
$ npm install eslint-plugin-storybook --save-dev | ||
``` | ||
## Usage | ||
@@ -26,26 +53,73 @@ | ||
{ | ||
"plugins": [ | ||
"storybook" | ||
] | ||
"plugins": ["storybook"] | ||
} | ||
``` | ||
Then, define which rule configurations to extend in your eslint file. Before that, it's important to understand that **Storybook linting rules should only be applied in your stories files**. You don't want rules to affect your other files such as production or test code as the rules might conflict with rules from other ESLint plugins. | ||
Then configure the rules you want to use under the rules section. | ||
### Run the plugin only against story files | ||
```json | ||
We don't want `eslint-plugin-storybook` to run against your whole codebase. To run this plugin only against your stories files, you have the following options: | ||
#### ESLint `overrides` | ||
One way of restricting ESLint config by file patterns is by using [ESLint `overrides`](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-based-on-glob-patterns). | ||
Assuming you are using the recommended `.stories` extension in your files, the following config would run `eslint-plugin-storybook` only against your stories files: | ||
```javascript | ||
// .eslintrc | ||
{ | ||
"rules": { | ||
"storybook/prefer-csf": "error" | ||
} | ||
} | ||
// 1) Here we have our usual config which applies to the whole project, so we don't put storybook preset here. | ||
"extends": ["airbnb", "plugin:prettier/recommended"], | ||
// 2) We load eslint-plugin-storybook globally with other ESLint plugins. | ||
"plugins": ["react-hooks", "storybook"], | ||
"overrides": [ | ||
{ | ||
// 3) Now we enable eslint-plugin-storybook rules or preset only for matching files! | ||
// you can use the one defined in your main.js | ||
"files": ['src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
"extends": ["plugin:storybook/recommended"], | ||
// 4) Optional: you can override specific rules here if you want. Else delete this | ||
"rules": { | ||
'storybook/no-redundant-story-name': 'error' | ||
} | ||
}, | ||
], | ||
}; | ||
``` | ||
#### ESLint Cascading and Hierarchy | ||
Another approach for customizing ESLint config by paths is through [ESLint Cascading and Hierarchy](https://eslint.org/docs/user-guide/configuring/configuration-files#cascading-and-hierarchy). This is useful if all your stories are placed under the same folder, so you can place there another `.eslintrc` where you enable `eslint-plugin-storybook` for applying it only to the files under such folder, rather than enabling it on your global `.eslintrc` which would apply to your whole project. | ||
## Supported Rules | ||
* prefer-csf: Display lint message when storiesOf API is used instead of the Component Story Format | ||
<!-- RULES-LIST:START --> | ||
**Key**: 🔧 = fixable | ||
**Configurations**: csf, csf-strict, addon-interactions, recommended | ||
| Name | Description | 🔧 | Included in configurations | | ||
| ------------------------------------------------------------------------------------------ | ------------------------------------------------- | --- | ------------------------------- | | ||
| [`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 | | ||
| [`storybook/default-exports`](./docs/rules/default-exports.md) | Story files should have a default export | | csf, recommended | | ||
| [`storybook/hierarchy-separator`](./docs/rules/hierarchy-separator.md) | Deprecated hierachy separator in title property | 🔧 | csf, recommended | | ||
| [`storybook/no-redundant-story-name`](./docs/rules/no-redundant-story-name.md) | A story should not have a redundant name property | 🔧 | csf, recommended | | ||
| [`storybook/no-stories-of`](./docs/rules/no-stories-of.md) | storiesOf is deprecated and should not be used | | csf-strict | | ||
| [`storybook/no-title-property-in-meta`](./docs/rules/no-title-property-in-meta.md) | Do not define a title in meta | 🔧 | csf-strict | | ||
| [`storybook/prefer-pascal-case`](./docs/rules/prefer-pascal-case.md) | Stories should use PascalCase | 🔧 | recommended | | ||
| [`storybook/use-storybook-expect`](./docs/rules/use-storybook-expect.md) | Use expect from `@storybook/jest` | 🔧 | addon-interactions, recommended | | ||
| [`storybook/use-storybook-testing-library`](./docs/rules/use-storybook-testing-library.md) | Do not use testing-library directly on stories | 🔧 | addon-interactions, recommended | | ||
<!-- RULES-LIST:END --> | ||
## Contributors | ||
Looking into improving this plugin? That would be awesome! | ||
Please refer to [the contributing guidelines](./CONTRIBUTING.md) for steps to contributing. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
53083
23
1013
0
1
125
3
23
1
+ Added@eslint-community/eslint-utils@4.4.0(transitive)
+ Added@eslint-community/regexpp@4.11.1(transitive)
+ Added@eslint/config-array@0.18.0(transitive)
+ Added@eslint/core@0.6.0(transitive)
+ Added@eslint/eslintrc@2.1.43.1.0(transitive)
+ Added@eslint/js@8.57.19.12.0(transitive)
+ Added@eslint/object-schema@2.1.4(transitive)
+ Added@eslint/plugin-kit@0.2.0(transitive)
+ Added@humanfs/core@0.19.0(transitive)
+ Added@humanfs/node@0.16.5(transitive)
+ Added@humanwhocodes/config-array@0.13.0(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@humanwhocodes/retry@0.3.1(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Added@types/semver@7.5.8(transitive)
+ Added@typescript-eslint/experimental-utils@5.62.0(transitive)
+ Added@typescript-eslint/scope-manager@5.62.0(transitive)
+ Added@typescript-eslint/types@5.62.0(transitive)
+ Added@typescript-eslint/typescript-estree@5.62.0(transitive)
+ Added@typescript-eslint/utils@5.62.0(transitive)
+ Added@typescript-eslint/visitor-keys@5.62.0(transitive)
+ Added@ungap/structured-clone@1.2.0(transitive)
+ Addedacorn@8.12.1(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addedajv@6.12.6(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddeep-is@0.1.4(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addeddoctrine@3.0.0(transitive)
+ Addedescape-string-regexp@4.0.0(transitive)
+ Addedeslint@8.57.19.12.0(transitive)
+ Addedeslint-scope@5.1.17.2.28.1.0(transitive)
+ Addedeslint-visitor-keys@3.4.34.1.0(transitive)
+ Addedespree@10.2.09.6.1(transitive)
+ Addedesquery@1.6.0(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@4.3.05.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-glob@3.3.2(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfast-levenshtein@2.0.6(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfile-entry-cache@6.0.18.0.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedflat-cache@3.2.04.0.1(transitive)
+ Addedflatted@3.3.1(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedglob-parent@5.1.26.0.2(transitive)
+ Addedglobals@13.24.014.0.0(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedjson-buffer@3.0.1(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stable-stringify-without-jsonify@1.0.1(transitive)
+ Addedkeyv@4.5.4(transitive)
+ Addedlevn@0.4.1(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedmerge2@1.4.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedms@2.1.3(transitive)
+ Addednatural-compare@1.4.0(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedoptionator@0.9.4(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedprelude-ls@1.2.1(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrequireindex@1.2.0(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedstrip-json-comments@3.1.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtext-table@0.2.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtsutils@3.21.0(transitive)
+ Addedtype-check@0.4.0(transitive)
+ Addedtype-fest@0.20.2(transitive)
+ Addedtypescript@5.6.2(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwhich@2.0.2(transitive)
+ Addedword-wrap@1.2.5(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedrequireindex@1.1.0(transitive)
Updatedrequireindex@^1.1.0