Skip to content

Commit

Permalink
fixed eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitali Zaidman committed Nov 14, 2021
1 parent 3f0f67b commit 0467b9d
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 40 deletions.
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
4 changes: 2 additions & 2 deletions demo/src/bigList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
whyDidYouRender(React);

class BigListPureComponent extends React.PureComponent {
static whyDidYouRender = { customName: 'BigList' }
static whyDidYouRender = { customName: 'BigList' };
render() {
return (
<div style={this.props.style}>
Expand All @@ -25,7 +25,7 @@ export default {

// Notice, that unlike the huge list, we don't track Main's re-renders because we don't care about it's re-renders.
class Main extends React.Component {
state = { count: 0 }
state = { count: 0 };
render() {
return (
<div style={{ height: '100%', width: '100%', display: 'flex', flexDirection: 'column' }}>
Expand Down
4 changes: 2 additions & 2 deletions demo/src/bothChanges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export default {
whyDidYouRender(React);

class ClassDemo extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;

state = {
c: { d: 'd' },
}
};

static getDerivedStateFromProps() {
return {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/childOfPureComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
}

class Main extends React.Component {
state = { clicksCount: 0 }
state = { clicksCount: 0 };
render() {
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/cloneElement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
whyDidYouRender(React);

class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/createFactory/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
whyDidYouRender(React);

class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return (
<div>
Expand Down
2 changes: 1 addition & 1 deletion demo/src/logOwnerReasons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
const Owner = () => <Child />;

class ClassOwner extends React.Component {
state = { a: 1 }
state = { a: 1 };
componentDidMount() {
this.setState({ a: 2 });
}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/noChanges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
whyDidYouRender(React);

class ClassDemo extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;

componentDidMount() {
stepLogger('forceUpdate', true);
Expand Down
2 changes: 1 addition & 1 deletion demo/src/specialChanges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
whyDidYouRender(React);

class ClassDemo extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;

render() {
return <div>Special Changes</div>;
Expand Down
4 changes: 2 additions & 2 deletions demo/src/stateChanges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export default {
whyDidYouRender(React);

class ClassDemo extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;

state = {
stateKey: 'stateValue',
}
};

componentDidMount() {
stepLogger('Set an existing state key with the same value', true);
Expand Down
2 changes: 1 addition & 1 deletion demo/src/strict/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
whyDidYouRender(React);

class ClassDemo extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>Props Changes</div>;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@welldone-software/why-did-you-render",
"version": "6.2.1",
"version": "6.2.2",
"description": "Monkey patches React to notify you about avoidable re-renders.",
"types": "types.d.ts",
"main": "dist/whyDidYouRender.js",
Expand Down
4 changes: 2 additions & 2 deletions tests/defaultNotifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import getUpdateInfo from '~/getUpdateInfo';
import whyDidYouRender from '~';

class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>hi!</div>;
}
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('logOnDifferentProps option', () => {
whyDidYouRender(React, { onlyLogs: true });

class OwnTestComponent extends React.Component {
static whyDidYouRender = { logOnDifferentValues: true }
static whyDidYouRender = { logOnDifferentValues: true };
render() {
return <div>hi!</div>;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('dont swallow errors', () => {
);
};

expect(mountBrokenComponent).toThrow("Cannot read properties of null (reading 'propTypes')");
expect(mountBrokenComponent).toThrow('Cannot read properties of null (reading \'propTypes\')');

expect(global.flushConsoleOutput()).toEqual([
{
Expand All @@ -53,7 +53,7 @@ test('dont swallow errors', () => {

test('render to static markup', () => {
class MyComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return (
<div>
Expand Down
12 changes: 7 additions & 5 deletions tests/librariesTests/react-router-dom.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ describe('react-router-dom-6', () => {
const InnerComp = () => {
const location = useLocation6();

// eslint-disable-next-line no-console
console.log(`location is: ${location.pathname}`);

return (
Expand All @@ -125,7 +126,7 @@ describe('react-router-dom-6', () => {
const Comp = () => (
<Router6>
<Routes6>
<Route6 exact path="/" element={<InnerComp/>}/>
<Route6 exact path="/" element={<InnerComp/>}/>
</Routes6>
</Router6>
);
Expand All @@ -136,8 +137,8 @@ describe('react-router-dom-6', () => {

const consoleOutputs = flushConsoleOutput();
expect(consoleOutputs).toEqual([
{level: 'log', args: ['location is: /']},
{level: 'log', args: ['location is: /']},
{ level: 'log', args: ['location is: /'] },
{ level: 'log', args: ['location is: /'] },
]);

expect(updateInfos).toHaveLength(3);
Expand All @@ -163,6 +164,7 @@ describe('react-router-dom-6', () => {
const InnerFn = ({ a, setDeepEqlState }) => {
const location = useLocation6();

// eslint-disable-next-line no-console
console.log(`location is: ${location.pathname}`);

React.useLayoutEffect(() => {
Expand Down Expand Up @@ -195,8 +197,8 @@ describe('react-router-dom-6', () => {

const consoleOutputs = flushConsoleOutput();
expect(consoleOutputs).toEqual([
{level: 'log', args: ['location is: /']},
{level: 'log', args: ['location is: /']},
{ level: 'log', args: ['location is: /'] },
{ level: 'log', args: ['location is: /'] },
]);

expect(updateInfos).toHaveLength(1);
Expand Down
4 changes: 2 additions & 2 deletions tests/logOwnerReasons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createOwners(Child) {
const Owner = () => <Child />;

class ClassOwner extends React.Component {
state = { a: 1 }
state = { a: 1 };
componentDidMount() {
this.setState({ a: 2 });
}
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('logOwnerReasons - function child', () => {

describe('logOwnerReasons - class child', () => {
class Child extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return null;
}
Expand Down
16 changes: 8 additions & 8 deletions tests/patches/patchClassComponent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import whyDidYouRender from '~';
import { diffTypes } from '~/consts';

class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>hi!</div>;
}
}

const createStateTestComponent = (initialState, newState) => {
return class StateTestComponent extends React.Component {
static whyDidYouRender = true
state = initialState
static whyDidYouRender = true;
state = initialState;
componentDidMount() {
this.setState(newState);
}
Expand Down Expand Up @@ -114,7 +114,7 @@ test('Props change', () => {
test('With implemented "componentDidUpdate()"', () => {
let innerComponentDidUpdateCalled = false;
class OwnTestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
componentDidUpdate() {
innerComponentDidUpdateCalled = true;
}
Expand Down Expand Up @@ -147,13 +147,13 @@ test('With implemented "componentDidUpdate()"', () => {

test('With render as an arrow function', () => {
class OwnTestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
componentDidMount() {
this.setState({ c: 'c' });
}
render = () => {
return <div>hi!</div>;
}
};
}

const { rerender } = rtl.render(
Expand Down Expand Up @@ -193,7 +193,7 @@ test('With render as an arrow function', () => {

test('With render as a binded function', () => {
class OwnTestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
constructor(props, context) {
super(props, context);
this.render = this.render.bind(this);
Expand Down Expand Up @@ -269,7 +269,7 @@ test('With implemented "componentDidUpdate()" with a snapshot - not tracked', ()
test('With implemented "componentDidUpdate()" with a snapshot', () => {
let resolve = false;
class OwnTestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
getSnapshotBeforeUpdate() {
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/shouldTrack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import shouldTrack from '~/shouldTrack';
import whyDidYouRender from '~';

class TrackedTestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>hi!</div>;
}
}

class TrackedTestComponentNoHooksTracking extends React.Component {
static whyDidYouRender = { trackHooks: false }
static whyDidYouRender = { trackHooks: false };
render() {
return <div>hi!</div>;
}
Expand All @@ -24,7 +24,7 @@ class NotTrackedTestComponent extends React.Component {
}

class ExcludedTestComponent extends React.Component {
static whyDidYouRender = false
static whyDidYouRender = false;
render() {
return <div>hi!</div>;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/strictMode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { diffTypes } from '~/consts';
import whyDidYouRender from '~';

class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>hi!</div>;
}
}

class PureTestComponent extends React.PureComponent {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
return <div>hi!</div>;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('checkIfInsideAStrictModeTree', () => {
test('class component', () => {
let isStrictMode;
class TestComponent extends React.Component {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
isStrictMode = checkIfInsideAStrictModeTree(this);
return <div>hi!</div>;
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('checkIfInsideAStrictModeTree', () => {
test('pure class component', () => {
let isStrictMode;
class TestComponent extends React.PureComponent {
static whyDidYouRender = true
static whyDidYouRender = true;
render() {
isStrictMode = checkIfInsideAStrictModeTree(this);
return <div>hi!</div>;
Expand Down

0 comments on commit 0467b9d

Please sign in to comment.