Skip to content

Commit

Permalink
Update the eslint configuration to allow editors to understand it
Browse files Browse the repository at this point in the history
Explicitly listing the .storybook/stories path in the package.json's `test:lint` invocation
works for ensuring that things get linted as part of the CI process, but VSCode (or any other
editor, for that matter) isn't aware of that and won't flag issues in these files. This leads
to multiple "fix warnings" commits and releases that are not working.

Instead this commit changes the .eslintignore file to explicitly un-ignore the .storybook directory
as advised by eslint/eslint#12348 (comment).

Note that this commit also fixes a bunch of now-reported warnings in other files that previously
got excluded.
  • Loading branch information
ankon committed Oct 2, 2020
1 parent 06b41ab commit c922661
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -4,3 +4,5 @@ node_modules/
storybook-static/
.snapshots/
*.min.js
# See https://github.com/eslint/eslint/issues/12348#issuecomment-536946429
!.storybook
1 change: 0 additions & 1 deletion .storybook/typings.d.ts
@@ -1,4 +1,3 @@

interface SvgrComponent
extends React.StatelessComponent<React.SVGAttributes<SVGElement>> {}

Expand Down
10 changes: 8 additions & 2 deletions .storybook/utils.ts
@@ -1,8 +1,14 @@
import { StoryFn, Annotations, Args } from '@storybook/addons';

type OptionalStoryInterface<Args, ReturnType> = Annotations<Args, ReturnType> & { storyName?: string };
type OptionalStoryInterface<Args, ReturnType> = Annotations<
Args,
ReturnType
> & { storyName?: string };

export function withDescription<T extends StoryFn<R> & OptionalStoryInterface<Args, R>, R>(storyDescription: string, story: T): T & OptionalStoryInterface<Args, R> {
export function withDescription<
T extends StoryFn<R> & OptionalStoryInterface<Args, R>,
R
>(storyDescription: string, story: T): T & OptionalStoryInterface<Args, R> {
story.parameters = {
...story.parameters,
docs: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -14,7 +14,7 @@
"build": "tsc --noEmit false",
"test": "run-s test:lint test:build test:unit",
"test:build": "tsc --noEmit -p tsconfig.test.json",
"test:lint": "eslint '*/**/*.{js,ts,tsx}' '.storybook/stories/**/*.{js,ts,tsx}'",
"test:lint": "eslint '*/**/*.{js,ts,tsx}'",
"test:unit": "cross-env CI=1 SKIP_PREFLIGHT_CHECK=true react-scripts test --env=jsdom --passWithNoTests",
"test:watch": "cross-env SKIP_PREFLIGHT_CHECK=true react-scripts test --env=jsdom",
"predeploy": "run-s storybook:build",
Expand Down

0 comments on commit c922661

Please sign in to comment.