Skip to content

Commit

Permalink
fix: Fix ESLint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed May 18, 2020
1 parent b039d1a commit e2665f6
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions __tests__/src/eventHandlers-test.js
Expand Up @@ -75,7 +75,7 @@ describe('eventHandlers', () => {
'onAnimationEnd',
'onAnimationIteration',
'onTransitionEnd',
].every(handlerName => includes(eventHandlers, handlerName)));
].every((handlerName) => includes(eventHandlers, handlerName)));
});
});

Expand All @@ -96,6 +96,6 @@ describe('eventHandlersByType', () => {
'image',
'animation',
'transition',
].every(type => !!eventHandlersByType[type]));
].every((type) => !!eventHandlersByType[type]));
});
});
4 changes: 2 additions & 2 deletions __tests__/src/getProp-parser-test.js
Expand Up @@ -162,11 +162,11 @@ function adjustNodeLocations(node, { startOffset, endOffset }) {

function adjustLocationsRecursively(node, { startOffset, endOffset }) {
if (Array.isArray(node)) {
return node.map(x => adjustLocationsRecursively(x, { startOffset, endOffset }));
return node.map((x) => adjustLocationsRecursively(x, { startOffset, endOffset }));
}
if (node && typeof node === 'object') {
return adjustNodeLocations(
mapValues(node, x => adjustLocationsRecursively(x, { startOffset, endOffset })),
mapValues(node, (x) => adjustLocationsRecursively(x, { startOffset, endOffset })),
{ startOffset, endOffset },
);
}
Expand Down
4 changes: 2 additions & 2 deletions __tests__/src/getPropLiteralValue-babelparser-test.js
Expand Up @@ -488,7 +488,7 @@ describe('getLiteralPropValue', () => {

describeIfNotBabylon('Typescript', () => {
beforeEach(() => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
});

it('should return string representation of variable identifier wrapped in a Typescript non-null assertion', () => {
Expand All @@ -510,7 +510,7 @@ describe('getLiteralPropValue', () => {
});

it('should return string representation of variable identifier wrapped in a Typescript type coercion', () => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
const prop = extractProp('<div foo={bar as any} />');

const expected = null;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/src/getPropLiteralValue-flowparser-test.js
Expand Up @@ -488,7 +488,7 @@ describe('getLiteralPropValue', () => {

describeIfNotBabylon('Typescript', () => {
beforeEach(() => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
});

it('should return string representation of variable identifier wrapped in a Typescript non-null assertion', () => {
Expand All @@ -510,7 +510,7 @@ describe('getLiteralPropValue', () => {
});

it('should return string representation of variable identifier wrapped in a Typescript type coercion', () => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
const prop = extractProp('<div foo={bar as any} />');

const expected = null;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/src/getPropValue-babelparser-test.js
Expand Up @@ -922,7 +922,7 @@ describe('getPropValue', () => {

describeIfNotBabylon('Typescript', () => {
beforeEach(() => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
});

it('should return string representation of variable identifier wrapped in a Typescript non-null assertion', () => {
Expand All @@ -944,7 +944,7 @@ describe('getPropValue', () => {
});

it('should return string representation of variable identifier wrapped in a Typescript type coercion', () => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
const prop = extractProp('<div foo={bar as any} />');

const expected = 'bar';
Expand Down
4 changes: 2 additions & 2 deletions __tests__/src/getPropValue-flowparser-test.js
Expand Up @@ -904,7 +904,7 @@ describe('getPropValue', () => {

describeIfNotBabylon('Typescript', () => {
beforeEach(() => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
});

it('should return string representation of variable identifier wrapped in a Typescript non-null assertion', () => {
Expand All @@ -926,7 +926,7 @@ describe('getPropValue', () => {
});

it('should return string representation of variable identifier wrapped in a Typescript type coercion', () => {
changePlugins(pls => [...pls, 'typescript']);
changePlugins((pls) => [...pls, 'typescript']);
const prop = extractProp('<div foo={bar as any} />');

const expected = 'bar';
Expand Down
6 changes: 3 additions & 3 deletions __tests__/src/index-test.js
Expand Up @@ -5,8 +5,8 @@ import assert from 'assert';
import core from '../../src/index';

const src = fs.readdirSync(path.resolve(__dirname, '../../src'))
.filter(f => f.indexOf('.js') >= 0)
.map(f => path.basename(f, '.js'));
.filter((f) => f.indexOf('.js') >= 0)
.map((f) => path.basename(f, '.js'));

describe('main export', () => {
it('should export an object', () => {
Expand All @@ -16,7 +16,7 @@ describe('main export', () => {
assert.equal(expected, actual);
});

src.filter(f => f !== 'index').forEach((f) => {
src.filter((f) => f !== 'index').forEach((f) => {
it(`should export ${f}`, () => {
assert.equal(
core[f],
Expand Down
4 changes: 2 additions & 2 deletions src/hasProp.js
Expand Up @@ -33,7 +33,7 @@ export default function hasProp(props = [], prop = '', options = DEFAULT_OPTIONS
export function hasAnyProp(nodeProps = [], props = [], options = DEFAULT_OPTIONS) {
const propsToCheck = typeof props === 'string' ? props.split(' ') : props;

return propsToCheck.some(prop => hasProp(nodeProps, prop, options));
return propsToCheck.some((prop) => hasProp(nodeProps, prop, options));
}

/**
Expand All @@ -43,5 +43,5 @@ export function hasAnyProp(nodeProps = [], props = [], options = DEFAULT_OPTIONS
export function hasEveryProp(nodeProps = [], props = [], options = DEFAULT_OPTIONS) {
const propsToCheck = typeof props === 'string' ? props.split(' ') : props;

return propsToCheck.every(prop => hasProp(nodeProps, prop, options));
return propsToCheck.every((prop) => hasProp(nodeProps, prop, options));
}
2 changes: 1 addition & 1 deletion src/values/expressions/ArrayExpression.js
Expand Up @@ -7,5 +7,5 @@
export default function extractValueFromArrayExpression(value) {
// eslint-disable-next-line global-require
const getValue = require('./index.js').default;
return value.elements.map(element => getValue(element));
return value.elements.map((element) => getValue(element));
}
2 changes: 1 addition & 1 deletion src/values/expressions/ObjectExpression.js
Expand Up @@ -10,7 +10,7 @@ export default function extractValueFromObjectExpression(value) {
// eslint-disable-next-line global-require
const getValue = require('./index.js').default;
return value.properties.reduce((obj, property) => {
const object = Object.assign({}, obj);
const object = { ...obj };
// Support types: SpreadProperty and ExperimentalSpreadProperty
if (/^(?:Experimental)?Spread(?:Property|Element)$/.test(property.type)) {
if (property.argument.type === 'ObjectExpression') {
Expand Down
9 changes: 5 additions & 4 deletions src/values/expressions/index.js
Expand Up @@ -48,7 +48,7 @@ const TYPES = {

const noop = () => null;

const errorMessage = expression => `The prop value with an expression type of ${expression} could not be resolved. Please file issue to get this fixed immediately.`;
const errorMessage = (expression) => `The prop value with an expression type of ${expression} could not be resolved. Please file issue to get this fixed immediately.`;

/**
* This function maps an AST value node
Expand Down Expand Up @@ -91,7 +91,8 @@ export default function extract(value) {
}

// Composition map of types to their extractor functions to handle literals.
const LITERAL_TYPES = Object.assign({}, TYPES, {
const LITERAL_TYPES = {
...TYPES,
Literal: (value) => {
const extractedVal = TYPES.Literal.call(undefined, value);
const isNull = extractedVal === null;
Expand Down Expand Up @@ -125,14 +126,14 @@ const LITERAL_TYPES = Object.assign({}, TYPES, {
NewExpression: noop,
ArrayExpression: (value) => {
const extractedVal = TYPES.ArrayExpression.call(undefined, value);
return extractedVal.filter(val => val !== null);
return extractedVal.filter((val) => val !== null);
},
BindExpression: noop,
SpreadElement: noop,
TSNonNullExpression: noop,
TSAsExpression: noop,
TypeCastExpression: noop,
});
};

/**
* This function maps an AST value node
Expand Down
5 changes: 3 additions & 2 deletions src/values/index.js
Expand Up @@ -10,10 +10,11 @@ const TYPES = {
};

// Composition map of types to their extractor functions to handle literals.
const LITERAL_TYPES = Object.assign({}, TYPES, {
const LITERAL_TYPES = {
...TYPES,
JSXElement: () => null,
JSXExpressionContainer: extractLiteral,
});
};

/**
* This function maps an AST value node
Expand Down

0 comments on commit e2665f6

Please sign in to comment.