Files
create-react-component-library/.storybook/main.js
Alejandro Lembke Barrientos a8e3057f02 PR-227028: update dependencies, migrate to TypeScript 6 and ESLint flat config
- Bump all dependencies to latest (React 19.2.7, Storybook 10.4.3, Webpack
  5.107.2 + webpack-cli 7, Jest 30.4.2, Cypress 15.17.0, Babel 7.29.7,
  sass-loader 17, css-minimizer-webpack-plugin 8, eslint-webpack-plugin 6).
- Migrate TypeScript 5.9 -> 6.0.3: set tsconfig rootDir, add
  ignoreDeprecations "6.0", scope include to src/components + src/@types, and
  declare *.scss/*.sass/*.css modules for stricter side-effect imports.
- Switch @babel/preset-react to the automatic JSX runtime and drop redundant
  React imports in stories and tests.
- Migrate ESLint from the deprecated .eslintrc.js to flat config
  (eslint.config.mjs) using typescript-eslint, @eslint/js, globals and the
  React/Storybook plugins. Keep ESLint at v9 because eslint-plugin-react does
  not support v10 yet. This fixes the previously broken lint (missing
  @typescript-eslint parser/plugin) and normalizes formatting.
- Fix a latent bug in .storybook/main.js (comma instead of semicolon joining
  two assignments via the comma operator).
- npm audit fix: 0 vulnerabilities.
- Bump package version to 1.4.0.
2026-06-09 17:33:58 +00:00

82 lines
1.9 KiB
JavaScript

const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const deFaultValues = {
PREFIX_URL: ''
};
const prefixUrl = process.env.PREFIX_URL ? process.env.PREFIX_URL : deFaultValues.PREFIX_URL;
module.exports = {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-webpack5-compiler-babel', '@storybook/addon-links', {
name: '@storybook/addon-styling-webpack',
options: {
rules: [
{
test: /\.(css|sass|scss)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
namedExport: false,
exportLocalsConvention: 'as-is',
auto: /\.module\.\w+$/i,
}
},
},
'sass-loader',
],
}
]
},
}, '@storybook/addon-docs'],
webpackFinal: async config => {
config.entry = config.entry.map(function(entry) {
if (entry.includes('webpack-hot-middleware')) {
return `${require.resolve('webpack-hot-middleware/client')}?path=${prefixUrl}__webpack_hmr&reload=true`;
}
return entry;
});
config.resolve.alias = {
...config.resolve.alias,
'@components': path.resolve(__dirname, '../src/components/')
};
config.resolve.plugins = [new TsconfigPathsPlugin()];
return config;
},
framework: {
name: '@storybook/react-webpack5',
options: {}
},
typescript: {
reactDocgenTypescriptOptions: {
compilerOptions: {
'paths': {
'@Components/*': ['Components/*']
}
},
propFilter: (prop) => {
// Filter out props that might contain Symbol values
if (prop.name && typeof prop.name === 'symbol') {
return false;
}
// Filter out React internal props that might cause issues
if (prop.name && prop.name.startsWith('$$')) {
return false;
}
return true;
}
}
},
docs: {
autodocs: 'tag',
defaultName: 'Docs',
}
};