Skip to content

Commit

Permalink
Add import/no-anonymous-default-export lint rule (#8926)
Browse files Browse the repository at this point in the history
  • Loading branch information
shakib609 authored May 4, 2020
1 parent 4974a20 commit 3c2f2d4
Show file tree
Hide file tree
Showing 41 changed files with 93 additions and 40 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ module.exports = {
// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
'import/first': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': 'warn',
'import/no-webpack-loader-syntax': 'error',

// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* LICENSE file in the root directory of this source tree.
*/

export default () => [
const absoluteLoad = () => [
{ id: 1, name: '1' },
{ id: 2, name: '2' },
{ id: 3, name: '3' },
{ id: 4, name: '4' },
];

export default absoluteLoad;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import load from 'absoluteLoad';

export default class extends Component {
export default class BaseUrl extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';

export default () => (
const ExpandEnvVariables = () => (
<span>
<span id="feature-expand-env-1">{process.env.REACT_APP_BASIC}</span>
<span id="feature-expand-env-2">{process.env.REACT_APP_BASIC_EXPAND}</span>
Expand All @@ -19,3 +19,5 @@ export default () => (
</span>
</span>
);

export default ExpandEnvVariables;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import React from 'react';

export default () => (
const FileEnvVariables = () => (
<span>
<span id="feature-file-env-original-1">
{process.env.REACT_APP_ORIGINAL_1}
Expand All @@ -22,3 +22,5 @@ export default () => (
<span id="feature-file-env-x">{process.env.REACT_APP_X}</span>
</span>
);

export default FileEnvVariables;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import React from 'react';

export default () => (
const PublicUrl = () => (
<span id="feature-public-url">{process.env.PUBLIC_URL}.</span>
);

export default PublicUrl;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

import React from 'react';

export default () => (
const ShellEnvVariables = () => (
<span id="feature-shell-env-variables">
{process.env.REACT_APP_SHELL_ENV_MESSAGE}.
</span>
);

export default ShellEnvVariables;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load() {
];
}

export default class extends Component {
export default class ArrayDestructuring extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load(users) {
];
}

export default class extends Component {
export default class ArraySpread extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const x = async (
};
/* eslint-enable */

export default class extends Component {
export default class AsyncAwait extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';

export default class extends Component {
export default class ClassProperties extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load(prefix) {
];
}

export default class extends Component {
export default class ComputedProperties extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function load() {
];
}

export default class extends Component {
export default class CustomInterpolation extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load(id = 0) {
];
}

export default class extends Component {
export default class DefaultParameters extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function load() {
};
}

export default class extends Component {
export default class DestructuringAndAwait extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function* load(limit) {
}
}

export default class extends Component {
export default class Generators extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load() {
];
}

export default class extends Component {
export default class NullishCoalescing extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load() {
];
}

export default class extends Component {
export default class ObjectDestructuring extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load(baseUser) {
];
}

export default class extends Component {
export default class ObjectSpread extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load() {
];
}

export default class extends Component {
export default class OptionalChaining extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load() {
]);
}

export default class extends Component {
export default class Promises extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) {
];
}

export default class extends Component {
export default class RestAndDefault extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load({ id = 0, ...rest }) {
];
}

export default class extends Component {
export default class RestParameters extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function load(name) {
];
}

export default class extends Component {
export default class TemplateInterpolation extends Component {
static propTypes = {
onReady: PropTypes.func.isRequired,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
import React from 'react';
import './assets/style.css';

export default () => <p id="feature-css-inclusion">We love useless text.</p>;
const CssInclusion = () => (
<p id="feature-css-inclusion">We love useless text.</p>
);

export default CssInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import React from 'react';
import styles from './assets/style.module.css';
import indexStyles from './assets/index.module.css';

export default () => (
const CssModulesInclusion = () => (
<div>
<p className={styles.cssModulesInclusion}>CSS Modules are working!</p>
<p className={indexStyles.cssModulesInclusion}>
CSS Modules with index are working!
</p>
</div>
);

export default CssModulesInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import React from 'react';

export default () => {
const DynamicImport = () => {
return <>Hello World!</>;
};

export default DynamicImport;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import React from 'react';
import tiniestCat from './assets/tiniest-cat.jpg';

export default () => (
const ImageInclusion = () => (
<img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" />
);

export default ImageInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
import React from 'react';
import { abstract } from './assets/abstract.json';

export default () => <summary id="feature-json-inclusion">{abstract}</summary>;
const JsonInclusion = () => (
<summary id="feature-json-inclusion">{abstract}</summary>
);

export default JsonInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import React from 'react';
import './assets/style.css';
import { test, version } from 'test-integrity';

export default () => {
const LinkedModules = () => {
const v = version();
if (!test() || v !== '2.0.0') {
throw new Error('Functionality test did not pass.');
}
return <p id="feature-linked-modules">{v}</p>;
};

export default LinkedModules;
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const text = aFileWithoutExt.includes('base64')
? atob(aFileWithoutExt.split('base64,')[1]).trim()
: aFileWithoutExt;

export default () => (
const NoExtInclusion = () => (
<a id="feature-no-ext-inclusion" href={text}>
aFileWithoutExt
</a>
);

export default NoExtInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
import React from 'react';
import './assets/sass-styles.sass';

export default () => <p id="feature-sass-inclusion">We love useless text.</p>;
const SassInclusion = () => (
<p id="feature-sass-inclusion">We love useless text.</p>
);

export default SassInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import React from 'react';
import styles from './assets/sass-styles.module.sass';
import indexStyles from './assets/index.module.sass';

export default () => (
const SassModulesInclusion = () => (
<div>
<p className={styles.sassModulesInclusion}>SASS Modules are working!</p>
<p className={indexStyles.sassModulesIndexInclusion}>
SASS Modules with index are working!
</p>
</div>
);

export default SassModulesInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
import React from 'react';
import './assets/scss-styles.scss';

export default () => <p id="feature-scss-inclusion">We love useless text.</p>;
const ScssInclusion = () => (
<p id="feature-scss-inclusion">We love useless text.</p>
);

export default ScssInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import React from 'react';
import styles from './assets/scss-styles.module.scss';
import indexStyles from './assets/index.module.scss';

export default () => (
const ScssModulesInclusion = () => (
<div>
<p className={styles.scssModulesInclusion}>SCSS Modules are working!</p>
<p className={indexStyles.scssModulesIndexInclusion}>
SCSS Modules with index are working!
</p>
</div>
);

export default ScssModulesInclusion;
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import React from 'react';
import { ReactComponent as Logo } from './assets/logo.svg';

export default () => {
const SvgComponent = () => {
return <Logo id="feature-svg-component" />;
};

export const SvgComponentWithRef = React.forwardRef((props, ref) => (
<Logo id="feature-svg-component-with-ref" ref={ref} />
));

export default SvgComponent;
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
import './assets/svg.css';

export default () => <div id="feature-svg-in-css" />;
const SvgInCss = () => <div id="feature-svg-in-css" />;

export default SvgInCss;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@
import React from 'react';
import logo from './assets/logo.svg';

export default () => <img id="feature-svg-inclusion" src={logo} alt="logo" />;
const SvgInclusion = () => (
<img id="feature-svg-inclusion" src={logo} alt="logo" />
);

export default SvgInclusion;
Loading

0 comments on commit 3c2f2d4

Please sign in to comment.