-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade Storybook to v7 #6499
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,17 @@ | |
} | ||
] | ||
} | ||
] | ||
], | ||
/* TODO: (FE-6306) - These rules have been added to allow us to | ||
* upgrade Storybook, but all rules will need to be looked at */ | ||
"no-restricted-exports": "off", | ||
"default-param-last": "off", | ||
"react/no-unstable-nested-components": "off", | ||
"react/jsx-no-constructed-context-values": "off", | ||
"react/jsx-no-useless-fragment": "off", | ||
"no-unsafe-optional-chaining": "off", | ||
"prefer-regex-literals": "off", | ||
"arrow-body-style": "off" | ||
}, | ||
"env": { | ||
"es6": true, | ||
|
@@ -106,14 +116,22 @@ | |
"plugin:react-hooks/recommended", | ||
"plugin:no-unsanitized/DOM", | ||
"airbnb", | ||
"prettier", | ||
"prettier/react" | ||
"prettier" | ||
], | ||
"globals": { | ||
"global": false, | ||
"process": false | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.mdx"], | ||
"extends": "plugin:mdx/recommended", | ||
"rules": { | ||
"jsx-a11y/anchor-has-content": "off", | ||
"jsx-a11y/control-has-associated-label": "off", | ||
"react/self-closing-comp": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"parser": "@typescript-eslint/parser", | ||
|
@@ -130,9 +148,10 @@ | |
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint" | ||
"prettier" | ||
], | ||
"settings": { | ||
"mdx/code-blocks": true, | ||
"react": { | ||
"version": "detect" | ||
} | ||
|
@@ -146,6 +165,13 @@ | |
"error", | ||
{ "allow": ["arrowFunctions"] } | ||
], | ||
"react/function-component-definition": [ | ||
"error", | ||
{ | ||
"namedComponents": "arrow-function", | ||
"unnamedComponents": "arrow-function" | ||
} | ||
], | ||
"no-restricted-imports": [ | ||
"error", | ||
{ | ||
|
@@ -156,6 +182,18 @@ | |
"react/prop-types": "off" | ||
} | ||
}, | ||
{ | ||
"files": ["*.stories.tsx"], | ||
"rules": { | ||
"react/function-component-definition": [ | ||
"error", | ||
{ | ||
"namedComponents": "arrow-function", | ||
"unnamedComponents": "arrow-function" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"files": ["*.spec.*"], | ||
"env": { | ||
|
@@ -173,7 +211,8 @@ | |
], | ||
"rules": { | ||
"jest/expect-expect": "off", | ||
"jest-dom/prefer-to-have-attribute": "off" | ||
"jest-dom/prefer-to-have-attribute": "off", | ||
"jest/no-alias-methods": "off" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment (non-blocking): it looks like these errors are easy to fix without turning the rule of - there's only a few places it flags errors, and these are all using But it's not a big deal so happy to leave it alone. |
||
} | ||
}, | ||
{ | ||
|
@@ -201,4 +240,4 @@ | |
} | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const allModes = { | ||
default: { | ||
viewport: 1280, | ||
}, | ||
chromatic: { | ||
viewport: { | ||
height: 1200, | ||
width: 900, | ||
}, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { create } from "@storybook/theming/create"; | ||
|
||
export default create({ | ||
base: "light", | ||
|
||
// Typography | ||
fontBase: '"Sage UI", sans-serif', | ||
fontCode: "monospace", | ||
|
||
brandTitle: "Carbon by Sage", | ||
brandUrl: "https://carbon.sage.com", | ||
brandImage: "carbon-by-sage-logo.png", | ||
|
||
colorPrimary: "#3A10E5", | ||
colorSecondary: "#007e45", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment (non-blocking): unlike the rules above, I'm really not keen on turning these off because they're about accessibility, not just code style. I've just played with it a bit and I'm not sure why we're getting flagged for these two - a lot of the failures seem to be in the same places for both and relate to anchor tags that have perfectly clear text content, so I don't know why that's failing.
As for self-closing-comp, this matters less (imo) but it should be an easy thing to fix where we have problems. Again though this is coming up in the same places, where it really shouldn't - so I think eslint is somehow misreading our code and this is giving rise to all 3 rule failures.
Happy to leave for now and open a new ticket to investigate - but I don't think we should just brush this under the carpet, and in that new ticket we should make a note to turn these rules back on when we've fixed whatever is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll double check these rules as per your comment when I go through all the suggestions etc but for the record we've never had linting on mdx files and as I recall when I've added it these weren't possible to "fix" as there was nothing actually wrong. As I say, I will double check this though and you're right we could maybe do some investigation but there is a ticket created to go through all of our linting rules and strip it back as there's a lot of rules that we're putting in just because it's in airbnb's ruleset and I believe it would better to simplify this a fair bit and have more control for the team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, I'd missed that we didn't have any linting on mdx before.
As I said, these seem to be failing for no good reason as they're on code that absolutely shouldn't fail these rules. Happy to have a new ticket to investigate so this PR doesn't get bogged down with it, but I don't want to just disable important accessibility-related checks and forget about it, even if we end up going with this as a temporary fix for now.