代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Material-UI 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const path = require('path');
const forbidTopLevelMessage = [
'Prefer one level nested imports to avoid bundling everything in dev mode',
'See https://github.com/mui/material-ui/pull/24147 for the kind of win it can unlock.',
].join('\n');
// This only applies to packages published from this monorepo.
// If you build a library around `@mui/material` you can safely use `createStyles` without running into the same issue as we are.
const forbidCreateStylesMessage =
'Use `MuiStyles<ClassKey, Props>` instead if the styles are exported. Otherwise use `as const` assertions. ' +
'`createStyles` will lead to inlined, at-compile-time-resolved type-imports. ' +
'See https://github.com/microsoft/TypeScript/issues/36097#issuecomment-578324386 for more information';
module.exports = {
root: true, // So parent files don't get applied
env: {
es6: true,
browser: true,
node: true,
},
extends: [
'plugin:import/recommended',
'plugin:import/typescript',
'airbnb-typescript',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 7,
},
plugins: [
'eslint-plugin-material-ui',
'eslint-plugin-react-hooks',
'@typescript-eslint/eslint-plugin',
],
settings: {
'import/resolver': {
webpack: {
config: path.join(__dirname, './webpackBaseConfig.js'),
},
},
},
/**
* Sorted alphanumerically within each group. built-in and each plugin form
* their own groups.
*/
rules: {
'consistent-this': ['error', 'self'],
curly: ['error', 'all'],
// Just as bad as "max components per file"
'max-classes-per-file': 'off',
// Too interruptive
'no-alert': 'error',
// Stylistic opinion
'arrow-body-style': 'off',
// Allow warn and error for dev environments
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-param-reassign': 'off', // It's fine.
// Airbnb use warn https://github.com/airbnb/javascript/blob/63098cbb6c05376dbefc9a91351f5727540c1ce1/packages/eslint-config-airbnb-base/rules/style.js#L97
// but eslint recommands error
'func-names': 'error',
'no-restricted-imports': [
'error',
{
patterns: [
'@mui/*/*/*',
// Begin block: Packages with files instead of packages in the top level
// Importing from the top level pulls in CommonJS instead of ES modules
// Allowing /icons as to reduce cold-start of dev builds significantly.
// There's nothing to tree-shake when importing from /icons this way:
// '@mui/icons-material/*/',
'@mui/utils/*',
// End block
// Macros are fine since their import path is transpiled away
'!@mui/utils/macros',
'@mui/utils/macros/*',
'!@mui/utils/macros/*.macro',
],
},
],
'no-constant-condition': 'error',
// Use the proptype inheritance chain
'no-prototype-builtins': 'off',
'no-underscore-dangle': 'error',
'nonblock-statement-body-position': 'error',
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
// Destructuring harm grep potential.
'prefer-destructuring': 'off',
// disabled type-aware linting due to performance considerations
'@typescript-eslint/dot-notation': 'off',
'dot-notation': 'error',
// disabled type-aware linting due to performance considerations
'@typescript-eslint/no-implied-eval': 'off',
'no-implied-eval': 'error',
// disabled type-aware linting due to performance considerations
'@typescript-eslint/no-throw-literal': 'off',
'no-throw-literal': 'error',
// disabled type-aware linting due to performance considerations
'@typescript-eslint/return-await': 'off',
'no-return-await': 'error',
// Not sure why it doesn't work
'import/named': 'off',
// Missing yarn workspace support
'import/no-extraneous-dependencies': 'off',
// The code is already coupled to webpack. Prefer explicit coupling.
'import/no-webpack-loader-syntax': 'off',
// doesn't work?
'jsx-a11y/label-has-associated-control': [
'error',
{
// airbnb uses 'both' which requires nesting i.e. <label><input /></label>
// 'either' allows `htmlFor`
assert: 'either',
},
],
// We are a library, we need to support it too
'jsx-a11y/no-autofocus': 'off',
'material-ui/docgen-ignore-before-comment': 'error',
'material-ui/rules-of-use-theme-variants': 'error',
'react-hooks/exhaustive-deps': ['error', { additionalHooks: 'useEnhancedEffect' }],
'react-hooks/rules-of-hooks': 'error',
'react/default-props-match-prop-types': [
'error',
{
// Otherwise the rule thinks inner props = outer props
// But in TypeScript we want to know that a certain prop is defined during render
// while it can be ommitted from the callsite.
// Then defaultProps (or default values) will make sure that the prop is defined during render
allowRequiredDefaults: true,
},
],
// Can add verbosity to small functions making them harder to grok.
// Though we have to manually enforce it for function components with default values.
'react/destructuring-assignment': 'off',
'react/forbid-prop-types': 'off', // Too strict, no time for that
'react/jsx-curly-brace-presence': 'off', // broken
// airbnb is using .jsx
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
// Prefer <React.Fragment> over <>.
'react/jsx-fragments': ['error', 'element'],
// Enforces premature optimization
'react/jsx-no-bind': 'off',
// We are a UI library.
'react/jsx-props-no-spreading': 'off',
// This rule is great for raising people awareness of what a key is and how it works.
'react/no-array-index-key': 'off',
'react/no-danger': 'error',
'react/no-direct-mutation-state': 'error',
// Not always relevant
'react/require-default-props': 'off',
'react/sort-prop-types': 'error',
// This depends entirely on what you're doing. There's no universal pattern
'react/state-in-constructor': 'off',
// stylistic opinion. For conditional assignment we want it outside, otherwise as static
'react/static-property-placement': 'off',
},
overrides: [
{
files: [
// matching the pattern of the test runner
'*.test.js',
'*.test.ts',
'*.test.tsx',
],
extends: ['plugin:mocha/recommended'],
rules: {
// does not work with wildcard imports. Mistakes will throw at runtime anyway
'import/named': 'off',
'no-restricted-imports': [
'error',
{
// Use named import from `test/utils` instead.
// The other files are private.
patterns: ['test/utils/*'],
},
],
'material-ui/disallow-active-element-as-key-event-target': 'error',
// upgraded level from recommended
'mocha/no-exclusive-tests': 'error',
'mocha/no-skipped-tests': 'error',
// no rationale provided in /recommended
'mocha/no-mocha-arrows': 'off',
// definitely a useful rule but too many false positives
// due to `describeConformance`
// "If you're using dynamically generated tests, you should disable this rule.""
'mocha/no-setup-in-describe': 'off',
// `beforeEach` for a single case is optimized for change
// when we add a test we don't have to refactor the existing
// test to `beforeEach`.
// `beforeEach`+`afterEach` also means that the `beforeEach`
// is cleaned up in `afterEach` if the test causes a crash
'mocha/no-hooks-for-single-case': 'off',
// disable eslint-plugin-jsx-a11y
// tests are not driven by assistive technology
// add `jsx-a11y` rules once you encounter them in tests
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/control-has-associated-label': 'off',
'jsx-a11y/iframe-has-title': 'off',
'jsx-a11y/label-has-associated-control': 'off',
'jsx-a11y/mouse-events-have-key-events': 'off',
'jsx-a11y/no-noninteractive-tabindex': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'jsx-a11y/tabindex-no-positive': 'off',
// In tests this is generally intended.
'react/button-has-type': 'off',
// They are accessed to test custom validator implementation with PropTypes.checkPropTypes
'react/forbid-foreign-prop-types': 'off',
// components that are defined in test are isolated enough
// that they don't need type-checking
'react/prop-types': 'off',
},
},
{
files: ['docs/src/modules/components/**/*.js'],
rules: {
'material-ui/no-hardcoded-labels': [
'error',
{ allow: ['MUI', 'Twitter', 'GitHub', 'Stack Overflow'] },
],
},
},
{
files: ['docs/pages/**/*.js'],
rules: {
'react/prop-types': 'off',
},
},
// demos
{
files: [
'docs/src/pages/**/*.js',
'docs/src/pages/**/*.tsx',
'docs/data/**/*.js',
'docs/data/**/*.tsx',
],
rules: {
// This most often reports data that is defined after the component definition.
// This is safe to do and helps readability of the demo code since the data is mostly irrelevant.
'@typescript-eslint/no-use-before-define': 'off',
'react/prop-types': 'off',
'no-alert': 'off',
'no-console': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'import/export': 'off', // Not sure why it doesn't work
},
},
{
files: ['*.tsx'],
excludedFiles: '*.spec.tsx',
rules: {
// WARNING: If updated, make sure these rules are merged with `no-restricted-imports` (#ts-source-files)
'no-restricted-imports': [
'error',
{
patterns: [
// Allow deeper imports for TypeScript types. TODO?
'@mui/*/*/*/*',
// Macros are fine since they're transpiled into something else
'!@mui/utils/macros/*.macro',
],
},
],
'react/prop-types': 'off',
},
},
// Files used for generating TypeScript declaration files (#ts-source-files)
{
files: ['packages/*/src/**/*.tsx'],
excludedFiles: '*.spec.tsx',
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@mui/material/styles',
importNames: ['createStyles'],
message: forbidCreateStylesMessage,
},
{
name: '@mui/styles',
importNames: ['createStyles'],
message: forbidCreateStylesMessage,
},
{
name: '@mui/styles/createStyles',
message: forbidCreateStylesMessage,
},
],
patterns: [
// Allow deeper imports for TypeScript types. TODO?
'@mui/*/*/*/*',
// Macros are fine since they're transpiled into something else
'!@mui/utils/macros/*.macro',
],
},
],
'react/prop-types': 'off',
},
},
{
files: ['*.spec.tsx', '*.spec.ts'],
rules: {
'no-alert': 'off',
'no-console': 'off',
'no-empty-pattern': 'off',
'no-lone-blocks': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
// Not sure why it doesn't work
'import/export': 'off',
'import/prefer-default-export': 'off',
'jsx-a11y/anchor-has-content': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/tabindex-no-positive': 'off',
'react/default-props-match-prop-types': 'off',
'react/no-access-state-in-setstate': 'off',
'react/no-unused-prop-types': 'off',
'react/prefer-stateless-function': 'off',
'react/prop-types': 'off',
'react/require-default-props': 'off',
'react/state-in-constructor': 'off',
'react/static-property-placement': 'off',
},
},
{
files: ['packages/typescript-to-proptypes/src/**/*.ts'],
rules: {
// Working with flags is common in TypeScript compiler
'no-bitwise': 'off',
},
},
{
files: ['packages/*/src/**/*{.ts,.tsx,.js}'],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@mui/material',
message: forbidTopLevelMessage,
},
{
name: '@mui/lab',
message: forbidTopLevelMessage,
},
],
},
],
},
},
{
files: ['packages/*/src/**/*{.ts,.tsx,.js}'],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx', 'packages/mui-joy/**/*{.ts,.tsx,.js}'],
rules: {
'material-ui/mui-name-matches-component-name': [
'error',
{
customHooks: [
'useDatePickerDefaultizedProps',
'useDateTimePickerDefaultizedProps',
'useTimePickerDefaultizedProps',
],
},
],
},
},
{
files: ['test/bundling/scripts/**/*.js'],
rules: {
// ES modules need extensions
'import/extensions': ['error', 'ignorePackages'],
},
},
],
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。