Skip to content

Commit

Permalink
Run ESLint on all source and test files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Jun 6, 2019
1 parent b8c0e87 commit 7a5f07a
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test/fixtures
test/ts/
*.ts
dist
6 changes: 3 additions & 3 deletions compat/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ options.event = e => {
};

let oldCatchRender = options.catchRender;
options.catchRender = (error, component) => {
return oldCatchRender && oldCatchRender(error, component) || catchRender(error, component);
};
options.catchRender = (error, component) => (
oldCatchRender && oldCatchRender(error, component) || catchRender(error, component)
);

/**
* Legacy version of createElement.
Expand Down
2 changes: 1 addition & 1 deletion compat/test/browser/memo.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setupRerender } from 'preact/test-utils';
import { setupRerender } from 'preact/test-utils';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { Component, render, createElement as h, memo } from '../../src';

Expand Down
25 changes: 13 additions & 12 deletions debug/src/check-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
let loggedTypeFailures = {};

export function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
Object.keys(typeSpecs).forEach((typeSpecName) => {
let error;
try {
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
} catch (e) {
error = e;
}
if (error && !(error.message in loggedTypeFailures)) {
loggedTypeFailures[error.message] = true;
console.error(`Failed ${location} type: ${error.message}${getStack && getStack() || ''}`);
}
});
Object.keys(typeSpecs).forEach((typeSpecName) => {
let error;
try {
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
}
catch (e) {
error = e;
}
if (error && !(error.message in loggedTypeFailures)) {
loggedTypeFailures[error.message] = true;
console.error(`Failed ${location} type: ${error.message}${getStack && getStack() || ''}`);
}
});
}
2 changes: 1 addition & 1 deletion debug/src/debug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { checkPropTypes } from './check-props';
import { getDisplayName } from './devtools/custom';
import { options, toChildArray } from 'preact';
import { options } from 'preact';
import { ELEMENT_NODE, DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE } from './constants';

export function initDebug() {
Expand Down
4 changes: 2 additions & 2 deletions hooks/test/_util/useEffectUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export function scheduleEffectAssert(assertFn) {
resolve();
}, 0)
);
})
}
});
}
5 changes: 0 additions & 5 deletions hooks/test/browser/useCallback.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { setupRerender } from 'preact/test-utils';
import { createElement as h, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useCallback } from '../../src';
Expand All @@ -11,12 +10,8 @@ describe('useCallback', () => {
/** @type {HTMLDivElement} */
let scratch;

/** @type {() => void} */
let rerender;

beforeEach(() => {
scratch = setupScratch();
rerender = setupRerender();
});

afterEach(() => {
Expand Down
1 change: 0 additions & 1 deletion hooks/test/browser/useMemo.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { setupRerender } from 'preact/test-utils';
import { createElement as h, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useMemo } from '../../src';
Expand Down
5 changes: 0 additions & 5 deletions hooks/test/browser/useRef.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { setupRerender } from 'preact/test-utils';
import { createElement as h, render } from 'preact';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { useRef } from '../../src';
Expand All @@ -11,12 +10,8 @@ describe('useRef', () => {
/** @type {HTMLDivElement} */
let scratch;

/** @type {() => void} */
let rerender;

beforeEach(() => {
scratch = setupScratch();
rerender = setupRerender();
});

afterEach(() => {
Expand Down
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"test:karma:test-utils": "cross-env PERFORMANCE=false COVERAGE=false karma start karma.conf.js --grep=test-utils/test/shared/**.js --no-single-run",
"test:karma:bench": "cross-env PERFORMANCE=true COVERAGE=false karma start karma.conf.js --grep=test/benchmarks/**.js --single-run",
"benchmark": "npm run test:karma:bench -- no-single-run",
"lint": "eslint src test",
"lint": "eslint src test debug compat hooks test-utils",
"postinstall": "node -e \"console.log('\\u001b[35m\\u001b[1mLove Preact? You can now donate to our open collective:\\u001b[22m\\u001b[39m\\n > \\u001b[34mhttps://opencollective.com/preact/donate\\u001b[0m')\""
},
"eslintConfig": {
Expand All @@ -41,6 +41,16 @@
}
},
"rules": {
"camelcase": [
1,
{
"allow": [
"__test__*",
"unstable_*",
"UNSAFE_*"
]
}
],
"prefer-rest-params": 0,
"prefer-spread": 0,
"no-cond-assign": 0,
Expand Down
7 changes: 3 additions & 4 deletions test-utils/test/shared/teardown.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { options, render } = require('preact');
const { teardown, setupRerender } = require('../../src');
const { options } = require('preact');
const { teardown } = require('../../src');
const { setupScratch } = require('../../../test/_util/helpers');

describe('teardown', () => {
let rerender, scratch;
let scratch;
beforeEach(() => {
rerender = setupRerender();
scratch = setupScratch();
});

Expand Down

0 comments on commit 7a5f07a

Please sign in to comment.