Skip to content

Commit

Permalink
[core] Use main repo as source of truth (mui#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Aug 7, 2020
1 parent f710e86 commit 1e17c08
Show file tree
Hide file tree
Showing 108 changed files with 6,097 additions and 2,180 deletions.
10 changes: 6 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/.git
/docs/.next
/docs/export
/packages/demo-app/public/static-data
/packages/grid/lib/lodash
/packages/grid/x-grid-modules/lib/autosizer
/packages/grid/x-grid-modules/lib/lodash
CHANGELOG.md
dist
node_modules
packages/demo-app/public/static-data
packages/grid/lib/lodash
packages/grid/x-grid-modules/lib/autosizer
packages/grid/x-grid-modules/lib/lodash
174 changes: 7 additions & 167 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
const baseline = require('@material-ui/monorepo/.eslintrc.js');
const path = require('path');

module.exports = {
root: true, // So parent files don't get applied
globals: {
preval: false, // Used in the documentation
},
...baseline,
env: {
es6: true,
browser: true,
node: true,
...baseline.env,
jest: true,
},
extends: [
'plugin:import/recommended',
'plugin:import/typescript',
'airbnb-typescript',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 7,
},
plugins: ['react-hooks', '@typescript-eslint'],
settings: {
'import/resolver': {
webpack: {
Expand All @@ -36,153 +19,10 @@ module.exports = {
* their own groups.
*/
rules: {
'consistent-this': ['error', 'self'],
// just as bad as "max components per file"
'max-classes-per-file': 'off',
'no-alert': 'error', // Too much interruptive
'no-console': ['error', { allow: ['warn', 'error'] }], // Allow warn and error for production events
'no-param-reassign': 'off', // It's fine.
'no-restricted-imports': [
'error',
{
patterns: [
'@material-ui/*/*/*',
'!@material-ui/core/test-utils/*',
'!@material-ui/utils/macros/*.macro',
],
},
],
'no-constant-condition': 'error',
'no-prototype-builtins': 'off', // Use the proptype inheritance chain
'no-underscore-dangle': 'error',
'nonblock-statement-body-position': 'error',
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'prefer-destructuring': 'off', // Destructuring harm grep potential.
'@typescript-eslint/dot-notation': 'off', // TODO performance consideration
'@typescript-eslint/no-implied-eval': 'off', // TODO performance consideration
'@typescript-eslint/no-throw-literal': 'off', // TODO performance consideration
'import/named': 'off', // Not sure why it doesn't work
'import/no-extraneous-dependencies': 'off', // Missing yarn workspace support
'jsx-a11y/label-has-associated-control': 'off', // doesn't work?
'jsx-a11y/no-autofocus': 'off', // We are a library, we need to support it too
'react-hooks/exhaustive-deps': ['warn', { additionalHooks: 'useEnhancedEffect' }],
'react-hooks/rules-of-hooks': 'warn',
'react/destructuring-assignment': 'off', // It's fine.
'react/forbid-prop-types': 'off', // Too strict, no time for that
'react/jsx-curly-brace-presence': 'off', // broken
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }], // airbnb is using .jsx
'react/jsx-fragments': ['error', 'element'], // Prefer <React.Fragment> over <>.
'react/jsx-props-no-spreading': 'off', // We are a UI library.
'react/no-array-index-key': 'off', // This rule is great for raising people awareness of what a key is and how it works.
'react/no-danger': 'error',
'react/no-direct-mutation-state': 'error',
'react/require-default-props': 'off', // Not always relevant
'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',

// TODO
'react/prop-types': 'off', // For public API
...baseline.rules,
'import/prefer-default-export': 'off',
// TODO
'no-restricted-imports': 'off',
'react-hooks/exhaustive-deps': ['warn', { additionalHooks: 'useEnhancedEffect' }],
},
overrides: [
{
files: ['*.test.tsx', '*.test.ts'],
env: {
mocha: true,
},
extends: ['plugin:mocha/recommended'],
rules: {
// does not work with wildcard imports. Mistakes will throw at runtime anyway
'import/named': 'off',
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@material-ui/core/test-utils',
importNames: ['createMount'],
message:
"Please use `import createMount from 'test/utils/createMount'` instead. `createMount` from /core has cleanup issues that require breaking changes.",
},
],
},
],

// 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/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',

// 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: ['packages/storybook/src/**/*.tsx'],
rules: {
'react/prop-types': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'import/export': 'off', // Not sure why it doesn't work
},
},
{
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',
'import/export': 'off', // Not sure why it doesn't work
'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',
},
},
],
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ __diff_output__
/.eslintcache
/.nyc_output
/coverage
/docs/.next
/docs/export
dist
node_modules
33 changes: 10 additions & 23 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,21 @@ module.exports = {
['@babel/plugin-transform-runtime', { version: '^7.4.4' }],
// for IE 11 support
'@babel/plugin-transform-object-assign',
'babel-plugin-istanbul',
[
'babel-plugin-module-resolver',
{
root: ['./'],
extensions: ['.js', '.ts', '.tsx'],
alias: defaultAlias,
},
],
],
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
coverage: {
plugins: [
'babel-plugin-istanbul',
[
'babel-plugin-module-resolver',
{
root: ['./'],
extensions: ['.js', '.ts', '.tsx'],
alias: defaultAlias,
},
],
],
},
coverage: {},
test: {
sourceMaps: 'both',
plugins: [
[
'babel-plugin-module-resolver',
{
root: ['./'],
extensions: ['.js', '.ts', '.tsx'],
alias: defaultAlias,
},
],
],
},
},
};
23 changes: 23 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Material-UI docs

This is the documentation website of Material-UI.

To start the docs site in development mode, from the project root, run:

```sh
yarn && yarn docs:dev
```

If you do not have yarn installed, select your OS and follow the instructions on the [Yarn website](https://yarnpkg.com/lang/en/docs/install/#mac-stable).

_DO NOT USE NPM, use Yarn to install the dependencies._

## How can I add a new demo to the documentation?

[You can follow this guide](https://github.com/mui-org/material-ui/blob/next/CONTRIBUTING.md)
on how to get started contributing to Material-UI.

## How do I help to improve the translations?

Please visit https://translate.material-ui.com/ where you will be able to select a language and edit the translations.
Please don't submit pull requests directly.
69 changes: 69 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const bpmr = require('babel-plugin-module-resolver');
const fse = require('fs-extra');
const path = require('path');

const errorCodesPath = path.resolve(__dirname, './public/static/error-codes.json');

function resolvePath(sourcePath, currentFile, opts) {
if (sourcePath === 'markdown') {
const base = currentFile.substring(__dirname.length).slice(0, -3);
return `${__dirname}/docs/src/${base}/`;
}

return bpmr.resolvePath(sourcePath, currentFile, opts);
}

const alias = {
'@material-ui/data-grid': '../packages/grid/data-grid/src',
'@material-ui/x-grid-modules': '../packages/grid/x-grid-modules/src',
'@material-ui/x-grid': '../packages/grid/x-grid/src',
'@material-ui/x-license': '../packages/license/src',
docs: './node_modules/@material-ui/monorepo/docs',
docsx: './',
modules: './node_modules/@material-ui/monorepo/modules',
// 'typescript-to-proptypes': './node_modules/@material-ui/monorepo/packages/typescript-to-proptypes',
};

const { version: transformRuntimeVersion } = fse.readJSONSync(
require.resolve('@babel/runtime-corejs2/package.json'),
);

module.exports = {
presets: [
// backport of https://github.com/zeit/next.js/pull/9511
['next/babel', { 'transform-runtime': { corejs: 2, version: transformRuntimeVersion } }],
],
plugins: [
[
'babel-plugin-macros',
{
muiError: {
errorCodesPath,
},
},
],
'babel-plugin-optimize-clsx',
// for IE 11 support
'@babel/plugin-transform-object-assign',
'babel-plugin-preval',
[
'babel-plugin-module-resolver',
{
alias,
transformFunctions: ['require', 'require.context'],
resolvePath,
},
],
],
ignore: [/@babel[\\|/]runtime/], // Fix a Windows issue.
env: {
production: {
plugins: [
'@babel/plugin-transform-react-constant-elements',
'babel-plugin-transform-dev-warning',
['babel-plugin-react-remove-properties', { properties: ['data-mui-test'] }],
['babel-plugin-transform-react-remove-prop-types', { mode: 'remove' }],
],
},
},
};
2 changes: 2 additions & 0 deletions docs/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
Loading

0 comments on commit 1e17c08

Please sign in to comment.