Skip to content

Commit

Permalink
Replace all 'Function' by () => {}, fixed CS
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskaya committed Feb 24, 2021
1 parent c5aef5f commit 5addc5f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
extends: [
'airbnb',
'plugin:jest/recommended',
Expand All @@ -22,5 +23,6 @@ module.exports = {
'import/prefer-default-export': 'off',
'react/prop-types': [0],
'react/jsx-props-no-spreading': 'off',
'linebreak-style': 0,
},
};
4 changes: 2 additions & 2 deletions src/Cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Cookies as ReactCookies } from 'react-cookie';
import { getExpirationDate } from './helpers';

export default class Cookies {
constructor(wholeDomain=false) {
constructor(wholeDomain = false) {
this.cookies = new ReactCookies();
this.whole_domain = wholeDomain;
}
Expand All @@ -15,7 +15,7 @@ export default class Cookies {
const optionPath = this.whole_domain ? { path: '/' } : {};
this.cookies.set(cookie, true, {
expires: cookieExpiration || getExpirationDate(),
...{optionPath}
...{ optionPath },
});
}

Expand Down
29 changes: 15 additions & 14 deletions src/components/CookieBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CookieBanner extends React.Component {
preferencesDefaultChecked = false,
statisticsDefaultChecked = false,
marketingDefaultChecked = false,
wholeDomain = false,
} = this.props;

this.state = {
Expand All @@ -34,7 +35,7 @@ class CookieBanner extends React.Component {
this.decline = this.decline.bind(this);
this.consetsCallback = this.consetsCallback.bind(this);

this.cookies = new Cookies(this.props.wholeDomain);
this.cookies = new Cookies(wholeDomain);
}

componentDidMount() {
Expand Down Expand Up @@ -81,9 +82,9 @@ class CookieBanner extends React.Component {

onAcceptAll() {
const {
onAcceptPreferences = Function,
onAcceptStatistics = Function,
onAcceptMarketing = Function,
onAcceptPreferences = () => {},
onAcceptStatistics = () => {},
onAcceptMarketing = () => {},
} = this.props;

this.cookies.set(CONSENT_GIVEN);
Expand Down Expand Up @@ -126,9 +127,9 @@ class CookieBanner extends React.Component {

decline() {
const {
onDeclinePreferences = Function,
onDeclineStatistics = Function,
onDeclineMarketing = Function,
onDeclinePreferences = () => {},
onDeclineStatistics = () => {},
onDeclineMarketing = () => {},
} = this.props;

this.cookies.set(CONSENT_GIVEN);
Expand All @@ -145,13 +146,13 @@ class CookieBanner extends React.Component {

consetsCallback() {
const {
onAccept = Function,
onAcceptPreferences = Function,
onAcceptStatistics = Function,
onAcceptMarketing = Function,
onDeclinePreferences = Function,
onDeclineStatistics = Function,
onDeclineMarketing = Function,
onAccept = () => {},
onAcceptPreferences = () => {},
onAcceptStatistics = () => {},
onAcceptMarketing = () => {},
onDeclinePreferences = () => {},
onDeclineStatistics = () => {},
onDeclineMarketing = () => {},
} = this.props;

const hasPreferencesCookie = this.cookies.get(PREFERENCES_COOKIE);
Expand Down
4 changes: 1 addition & 3 deletions src/components/CookieBanner.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import CookieBanner from './CookieBanner';
import CookieBannerContent from './CookieBannerContent';

describe('CookieBanner component', () => {
beforeEach((done) => {
beforeEach(() => {
document.cookie.split(';').forEach((cookie) => {
const eqPos = cookie.indexOf('=');
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`;
});

done();
});

test('should be rendered', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/CookieBannerContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class CookieBannerContent extends React.Component {
acceptButtonText = 'Accept all',
managePreferencesButtonText = 'Mange my cookies',
savePreferencesButtonText = 'Save and close',
onConfirm = Function,
onAcceptAll = Function,
onConfirm = () => {},
onAcceptAll = () => {},
} = this.props;

const { showPreferences } = this.state;
Expand Down
6 changes: 3 additions & 3 deletions src/components/CookieBannerPreferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export default (props = {}) => {
preferencesDefaultChecked = false,
statisticsDefaultChecked = false,
marketingDefaultChecked = false,
onTogglePreferencesCookies = Function,
onToggleStatisticsCookies = Function,
onToggleMarketingCookies = Function,
onTogglePreferencesCookies = () => {},
onToggleStatisticsCookies = () => {},
onToggleMarketingCookies = () => {},
} = props;

const {
Expand Down
12 changes: 6 additions & 6 deletions src/components/CookieBannerPreferences.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe('CookieBannerPreferences component', () => {
preferencesDefaultChecked: false,
statisticsDefaultChecked: false,
marketingDefaultChecked: false,
onTogglePreferencesCookies: Function,
onToggleStatisticsCookies: Function,
onToggleMarketingCookies: Function,
onTogglePreferencesCookies: () => {},
onToggleStatisticsCookies: () => {},
onToggleMarketingCookies: () => {},
};

const component = mount(
Expand All @@ -42,9 +42,9 @@ describe('CookieBannerPreferences component', () => {
};

expect(component.contains(<CookieOption id="check-required-cookies" text="Necessary" disabled checked styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-preferences-cookies" text="Preferences" checked={false} onChange={Function} styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-statistics-cookies" text="Statistics" checked={false} onChange={Function} styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-marketing-cookies" text="Marketing" checked={false} onChange={Function} styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-preferences-cookies" text="Preferences" checked={false} onChange={props.onTogglePreferencesCookies} styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-statistics-cookies" text="Statistics" checked={false} onChange={props.onToggleStatisticsCookies} styles={cookieOptionStyle} />)).toBeTruthy();
expect(component.contains(<CookieOption id="check-marketing-cookies" text="Marketing" checked={false} onChange={props.onToggleMarketingCookies} styles={cookieOptionStyle} />)).toBeTruthy();
});

test('should hide preferences checkbox', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CookieOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CookieOption extends React.Component {
}

handleOnChange() {
const { onChange = Function } = this.props;
const { onChange = () => {} } = this.props;
const { checked } = this.state;
const newValue = !checked;

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import React from 'react';
import CookieBanner from './components/CookieBanner';
import { isServer } from './helpers';

const CookieBannerUniversal = props => (isServer() ? null : <CookieBanner {...props} />);
const CookieBannerUniversal = (props) => (isServer() ? null : <CookieBanner {...props} />);

export { CookieBannerUniversal as CookieBanner };

0 comments on commit 5addc5f

Please sign in to comment.