Skip to content

Commit

Permalink
second iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 12, 2020
1 parent ffed74f commit 935ebfb
Show file tree
Hide file tree
Showing 152 changed files with 282 additions and 290 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/packages/material-ui-icons/legacy
/packages/material-ui-icons/src
/packages/material-ui-icons/templateSvgIcon.js
# Not important?
/packages/typescript-to-proptypes/
/framer/
# Ignore fixtures
/packages/typescript-to-proptypes/test/**/*.js
/tmp
Expand Down
94 changes: 62 additions & 32 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ module.exports = {
browser: true,
node: true,
},
extends: ['plugin:import/recommended', 'airbnb-typescript', 'prettier', 'prettier/react', 'prettier/@typescript-eslint'],
extends: [
'plugin:import/recommended',
'plugin:import/typescript',
'airbnb-typescript',
'prettier',
'prettier/react',
'prettier/@typescript-eslint',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
// project: './tsconfig.json',
},
plugins: ['material-ui', 'react-hooks', '@typescript-eslint'],
settings: {
Expand All @@ -26,31 +33,45 @@ module.exports = {
},
// Sorted alphanumerically
rules: {
'@typescript-eslint/dot-notation': 'off', // Too slow
'@typescript-eslint/no-implied-eval': 'off', // Too slow
'@typescript-eslint/no-throw-literal': 'off', // Too slow
'consistent-this': ['error', 'self'],
'import/export': 'off', // Not sure why it doesn't work
'import/named': 'off', // Not sure why it doesn't work
'import/no-cycle': 'off', // Too slow
'import/no-extraneous-dependencies': 'off', // Missing yarn workspace support
'no-console': ['error', { allow: ['warn', 'error'] }], // More strict than airbnb. Allow warn and error for production events
'no-param-reassign': 'off', // Less strict than airbnb. It's fine.
'react/destructuring-assignment': 'off', // Less strict than airbnb. It's fine.
'jsx-a11y/label-has-associated-control': 'off', // doesn't work?
'max-classes-per-file': 'off', // just as bad as "max components per file"
'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',
],
},
],
'prefer-destructuring': 'off', // Destructuring harm grep potential.
'react/destructuring-assignment': 'off', // It's fine.
'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', // Less strict than airbnb. We are a UI library.
'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/require-default-props': 'off', // Not always relevant
'react/static-property-placement': 'off', // No needed
'react/forbid-prop-types': 'off', // Too strict, no time for that
'react/no-find-dom-node': 'off', // Required for backward compatibility. TODO v5, drop

// 'consistent-this': ['error', 'self'],
// 'linebreak-style': 'off', // Doesn't play nicely with Windows
// // just as bad as "max components per file"
// 'max-classes-per-file': 'off',
// 'no-alert': 'error',
// 'no-constant-condition': 'error',
// // Airbnb use error
// 'no-prototype-builtins': 'off',
// 'no-restricted-imports': [
// 'error',
// {
// patterns: [
// '@material-ui/*/*/*',
// '!@material-ui/core/test-utils/*',
// '!@material-ui/utils/macros/*.macro',
// ],
// },
// ],
// 'nonblock-statement-body-position': 'error',
// // Airbnb restricts isNaN and isFinite which are necessary for IE 11
// // we have to be disciplined about the usage and ensure the Number type for its
Expand All @@ -60,18 +81,12 @@ module.exports = {
// 'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
// 'prefer-destructuring': 'off', // Destructuring harm grep potential.

// 'jsx-a11y/label-has-associated-control': 'off',
// 'jsx-a11y/label-has-for': 'off', // deprecated
// 'jsx-a11y/no-autofocus': 'off', // We are a library, people do what they want.

// 'material-ui/docgen-ignore-before-comment': 'error',

// // This rule is great for raising people awareness of what a key is and how it works.
// 'react/no-array-index-key': 'off',
// // It's buggy
// 'react/forbid-prop-types': 'off',
// 'react/jsx-curly-brace-presence': 'off',
// 'react/jsx-filename-extension': ['error', { extensions: ['.js'] }], // airbnb is using .jsx
// 'react/jsx-handler-names': [
// 'error',
// {
Expand All @@ -84,14 +99,10 @@ module.exports = {
// 'react/no-danger': 'error',
// // Strict, airbnb is using off
// 'react/no-direct-mutation-state': 'error',
// 'react/no-find-dom-node': 'off',
// 'react/no-multi-comp': 'off',
// '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',
// 'import/namespace': ['error', { allowComputed: true }],
// 'import/order': [
// 'error',
Expand Down Expand Up @@ -186,14 +197,33 @@ module.exports = {
},
},
{
files: ['*.spec.tsx'],
files: ['*.tsx'],
rules: {
'react/prop-types': 'off',
},
},
{
files: ['*.spec.tsx', '*.spec.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'max-classes-per-file': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'import/prefer-default-export': 'off',
'jsx-a11y/anchor-has-content': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'no-alert': 'off',
'no-console': 'off',
'no-empty-pattern': 'off',
'no-lone-blocks': 'off',
'no-shadow': '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',
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/buildApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import * as babel from '@babel/core';
import traverse from '@babel/traverse';
import { mkdirSync, readFileSync, writeFileSync } from 'fs';
import { getLineFeed } from './helpers';
import { rewriteUrlForNextExport } from 'next/dist/next-server/lib/router/rewrite-url-for-export';
import path from 'path';
import kebabCase from 'lodash/kebabCase';
Expand All @@ -11,6 +10,7 @@ import { defaultHandlers, parse as docgenParse } from 'react-docgen';
import remark from 'remark';
import remarkVisit from 'unist-util-visit';
import * as yargs from 'yargs';
import { getLineFeed } from './helpers';
import muiDefaultPropsHandler from '../src/modules/utils/defaultPropsHandler';
import generateMarkdown from '../src/modules/utils/generateMarkdown';
import { findPagesMarkdown, findComponents } from '../src/modules/utils/find';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function renderNavItems(options) {
return (
<List>
{pages.reduce(
// eslint-disable-next-line no-use-before-define
// eslint-disable-next-line @typescript-eslint/no-use-before-define
(items, page) => reduceChildRoutes({ items, page, ...params }),
[],
)}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/HighlightedCode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import * as PropTypes from 'prop-types';
import MarkdownElement from './MarkdownElement';
import prism from 'docs/src/modules/utils/prism';
import MarkdownElement from './MarkdownElement';

const HighlightedCode = React.forwardRef(function HighlightedCode(props, ref) {
const { code, language, ...other } = props;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { parse as parseDoctrine } from 'doctrine';
import * as recast from 'recast';
import { parse as docgenParse } from 'react-docgen';
import { rewriteUrlForNextExport } from 'next/dist/next-server/lib/router/rewrite-url-for-export';
import { pageToTitle } from './helpers';
import { SOURCE_CODE_ROOT_URL, LANGUAGES_IN_PROGRESS } from 'docs/src/modules/constants';
import { pageToTitle } from './helpers';

const PATH_REPLACE_REGEX = /\\/g;
const PATH_SEPARATOR = '/';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/getDemoConfig.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getDependencies } from './helpers';
import { CODE_VARIANTS } from 'docs/src/modules/constants';
import { getDependencies } from './helpers';

function jsDemo(demoData) {
return {
Expand Down
3 changes: 1 addition & 2 deletions docs/src/pages/components/autocomplete/CheckboxesTags.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-use-before-define */

/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Checkbox from '@material-ui/core/Checkbox';
import TextField from '@material-ui/core/TextField';
Expand Down
3 changes: 1 addition & 2 deletions docs/src/pages/components/autocomplete/CheckboxesTags.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-use-before-define */

/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Checkbox from '@material-ui/core/Checkbox';
import TextField from '@material-ui/core/TextField';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/ComboBox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/ComboBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/CountrySelect.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/CountrySelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/CustomizedHook.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import useAutocomplete from '@material-ui/lab/useAutocomplete';
import NoSsr from '@material-ui/core/NoSsr';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/CustomizedHook.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import useAutocomplete from '@material-ui/lab/useAutocomplete';
import NoSsr from '@material-ui/core/NoSsr';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/DisabledOptions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/DisabledOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Filter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/FixedTags.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Chip from '@material-ui/core/Chip';
import TextField from '@material-ui/core/TextField';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/FixedTags.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Chip from '@material-ui/core/Chip';
import TextField from '@material-ui/core/TextField';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/FreeSolo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/FreeSolo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Dialog from '@material-ui/core/Dialog';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/GitHubLabel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import { useTheme, fade, makeStyles } from '@material-ui/core/styles';
import Popper from '@material-ui/core/Popper';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/GitHubLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import {
useTheme,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Grouped.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Grouped.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Highlights.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Highlights.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/LimitTags.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { makeStyles } from '@material-ui/core/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/LimitTags.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import Autocomplete from '@material-ui/lab/Autocomplete';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Playground.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/autocomplete/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-use-before-define */
/* eslint-disable @typescript-eslint/no-use-before-define */
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
Expand Down
Loading

0 comments on commit 935ebfb

Please sign in to comment.