-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: monorepo eslint upgrade to flat config (#435)
* adds .history folder to gitignore * linting passes * remove old eslint config files * remove --debug from eslint cli
- Loading branch information
Showing
26 changed files
with
414 additions
and
21,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
shamefully-hoist=true | ||
shamefully-hoist=true | ||
package-manager-strict=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-disable prettier/prettier */ | ||
// eslint.config.js | ||
import config from '@explorer-1/eslint-config' | ||
|
||
export default [ | ||
...config, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,84 @@ | ||
import { useEffect, useGlobals } from '@storybook/preview-api'; | ||
import { useEffect, useGlobals } from '@storybook/preview-api' | ||
|
||
const getThemes = (themesConfig) => { | ||
// default values | ||
let defaultMethod: string = 'css'; | ||
let options: string[] | undefined = undefined; | ||
let method: string | undefined = undefined; | ||
let defaultMethod: string = 'css' | ||
let options: string[] | undefined = undefined | ||
let method: string | undefined = undefined | ||
|
||
if (typeof themesConfig === 'object') { | ||
// handle theme | ||
if ('themeSwitcher' in themesConfig) { | ||
if ( | ||
Array.isArray(themesConfig.defaultValue) && | ||
themesConfig.defaultValue.length > 0 | ||
) { | ||
options = themesConfig.defaultValue; | ||
if (Array.isArray(themesConfig.defaultValue) && themesConfig.defaultValue.length > 0) { | ||
options = themesConfig.defaultValue | ||
} else { | ||
options = undefined; | ||
options = undefined | ||
} | ||
} | ||
|
||
// handle method | ||
if ('method' in themesConfig) { | ||
// case insensitive comparisons | ||
if (themesConfig.method.toUpperCase() === 'data-theme'.toUpperCase()) { | ||
method = 'data-theme'; | ||
method = 'data-theme' | ||
} else if (themesConfig.method.toUpperCase() === 'css'.toUpperCase()) { | ||
method = 'css'; | ||
method = 'css' | ||
} else { | ||
// use "css" method if not specified | ||
method = defaultMethod; | ||
method = defaultMethod | ||
} | ||
} else { | ||
method = defaultMethod; | ||
method = defaultMethod | ||
} | ||
} | ||
|
||
// otherwise undefined | ||
else { | ||
options = undefined; | ||
method = undefined; | ||
options = undefined | ||
method = undefined | ||
} | ||
|
||
return { options, method }; | ||
}; | ||
return { options, method } | ||
} | ||
|
||
export const withGlobals = (StoryFn, context) => { | ||
const { themesConfig } = context.globals; | ||
const { options, method } = getThemes(themesConfig); | ||
const [{ theme }, updateGlobals] = useGlobals(); | ||
const isInDocs = context.viewMode === 'docs'; | ||
const { themesConfig } = context.globals | ||
const { options, method } = getThemes(themesConfig) | ||
const [{ theme }, updateGlobals] = useGlobals() | ||
const isInDocs = context.viewMode === 'docs' | ||
|
||
// disable usage of updateGlobals in docs | ||
if (!isInDocs) { | ||
// check for value in local storage | ||
useEffect(() => { | ||
const savedTheme = window.localStorage.getItem('data-theme'); | ||
const savedTheme = window.localStorage.getItem('data-theme') | ||
if (savedTheme) { | ||
// update theme attribute and save it to local storage | ||
updateGlobals({ theme: savedTheme }); | ||
updateGlobals({ theme: savedTheme }) | ||
} else { | ||
// set it to the first theme | ||
if (options && options.length > 0) { | ||
updateGlobals({ theme: options[0] }); | ||
updateGlobals({ theme: options[0] }) | ||
} | ||
} | ||
}, []); | ||
}, []) | ||
} | ||
|
||
if (method === 'css') { | ||
useEffect(() => { | ||
if (theme) { | ||
document.documentElement.setAttribute('class', theme); | ||
window.localStorage.setItem('data-theme', theme); | ||
document.documentElement.setAttribute('class', theme) | ||
window.localStorage.setItem('data-theme', theme) | ||
} | ||
}, [theme]); | ||
}, [theme]) | ||
} else if (method === 'data-theme') { | ||
useEffect(() => { | ||
if (theme) { | ||
document.documentElement.setAttribute('data-theme', theme); | ||
window.localStorage.setItem('data-theme', theme); | ||
document.documentElement.setAttribute('data-theme', theme) | ||
window.localStorage.setItem('data-theme', theme) | ||
} | ||
}, [theme]); | ||
}, [theme]) | ||
} | ||
|
||
return StoryFn(); | ||
}; | ||
return StoryFn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.