Skip to content

Commit

Permalink
Merge pull request reactjs#173 from JetRunner/master
Browse files Browse the repository at this point in the history
Fix ESLint Warnings & Add .eslintignore
  • Loading branch information
bvaughn authored Sep 18, 2017
2 parents d8a1d47 + e430a2a commit 4ca059d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
__testfixtures__
4 changes: 3 additions & 1 deletion transforms/React-PropTypes-to-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ module.exports = function(file, api, options) {
// Add back any nested destructured children.
if (nestedPropTypesChildren) {
// TODO: This shouldn't just use a template string but the `ast-types` docs were too opaque for me to follow.
const propTypeChildren = nestedPropTypesChildren.value.properties.map(property => property.key.name).join(', ');
const propTypeChildren = nestedPropTypesChildren.value.properties.map(
property => property.key.name
).join(', ');
const destructureStatement = j.template.statement([`const { ${propTypeChildren} } = ${localPropTypesName};`]);

j(path.parent.parent).insertBefore(destructureStatement);
Expand Down
16 changes: 8 additions & 8 deletions transforms/ReactNative-View-propTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

const isReactNativeImport = path => (
path.parent.node.source.value === 'react-native'
)
);

const isReactNativeRequire = path => (
path.node.arguments.some(argument => argument.value === 'react-native')
)
);

const isRootViewReference = path => (
path.node.name === 'View' &&
Expand Down Expand Up @@ -102,7 +102,7 @@ module.exports = function(file, api, options) {
.length === 0;

// Determine which kind of import/require() we should create based on file contents
let useHasteModules = false
let useHasteModules = false;
if (fileUsesImports) {
useHasteModules = root
.find(j.ImportSpecifier)
Expand All @@ -118,15 +118,15 @@ module.exports = function(file, api, options) {
// Create a require statement or an import, based on file convention
let importOrRequireStatement;
if (fileUsesImports) {
const identifier = j.identifier('ViewPropTypes');
const variable = useHasteModules === true
const identifier = j.identifier('ViewPropTypes');
const variable = useHasteModules === true
? j.importDefaultSpecifier(identifier)
: j.importSpecifier(identifier);
const source = useHasteModules === true
const source = useHasteModules === true
? 'ViewPropTypes'
: 'react-native'
: 'react-native';

importOrRequireStatement = j.importDeclaration(
importOrRequireStatement = j.importDeclaration(
[variable], j.literal(source)
);
} else {
Expand Down
8 changes: 4 additions & 4 deletions transforms/__tests__/error-boundaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*
*/

"use strict";
'use strict';

const tests = ["class-component", "create-class-component"];
const tests = ['class-component', 'create-class-component'];

const defineTest = require("jscodeshift/dist/testUtils").defineTest;
const defineTest = require('jscodeshift/dist/testUtils').defineTest;

tests.forEach(test => {
defineTest(__dirname, "error-boundaries", null, `error-boundaries/${test}`);
defineTest(__dirname, 'error-boundaries', null, `error-boundaries/${test}`);
});
2 changes: 1 addition & 1 deletion transforms/__tests__/react-to-react-dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ describe('react-to-react-dom', () => {
null,
`react-to-react-dom/${ test }`
)
)
);
});
4 changes: 2 additions & 2 deletions transforms/create-element-to-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = function(file, api, options) {
return {
attributes: [],
extraComments: expression.comments || [],
}
};
} else {
throw new Error(`Unexpected attribute of type "${expression.type}"`);
}
Expand All @@ -141,7 +141,7 @@ module.exports = function(file, api, options) {
comments: propertyComments
} = jsxIdentifierFor(node.property);
identifier = j.jsxMemberExpression(objectIdentifier, propertyIdentifier);
comments.push(...objectComments, ...propertyComments)
comments.push(...objectComments, ...propertyComments);
} else {
identifier = j.jsxIdentifier(node.name);
}
Expand Down
4 changes: 2 additions & 2 deletions transforms/error-boundaries.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module.exports = function(file, api, options) {
return j(file.source)
.find(j.Identifier)
.forEach(path => {
if (path.node.name === "unstable_handleError") {
j(path).replaceWith(j.identifier("componentDidCatch"));
if (path.node.name === 'unstable_handleError') {
j(path).replaceWith(j.identifier('componentDidCatch'));
}
})
.toSource();
Expand Down
5 changes: 3 additions & 2 deletions transforms/react-to-react-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ module.exports = function(file, api) {
}
coreImportDeclaration = p;
var defaultSpecifier = p.value.specifiers.find(sp => sp.type === j.ImportDefaultSpecifier.name);
var specifiers = p.value.specifiers.filter(sp => sp.type === j.ImportSpecifier.name);
if (defaultSpecifier) {
var name = defaultSpecifier.local.name;
var scope = p.scope.lookup(name);
Expand Down Expand Up @@ -352,7 +351,9 @@ module.exports = function(file, api) {
}

function emitImport(name, path, knownProperties, uses) {
const usedProperties = coreImportDeclaration.value.specifiers.filter(sp => sp.type === j.ImportSpecifier.name).filter(sp =>
const usedProperties = coreImportDeclaration.value.specifiers.filter(
sp => sp.type === j.ImportSpecifier.name
).filter(sp =>
sp.imported.type === 'Identifier' && knownProperties.indexOf(sp.imported.name) !== -1
).map(sp => sp.imported.name);

Expand Down
4 changes: 3 additions & 1 deletion transforms/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
/**
* Reorders React component methods to match the [ESLint](http://eslint.org/)
* [react/sort-comp rule](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md),
* specifically with the [tighter constraints of the Airbnb style guide](https://github.com/airbnb/javascript/blob/7684892951ef663e1c4e62ad57d662e9b2748b9e/packages/eslint-config-airbnb/rules/react.js#L122-L134),
* specifically with the [tighter constraints of the Airbnb style guide]
* (https://github.com/airbnb/javascript/blob/7684892951ef663e1c4e62ad57d662e9b2748b9e/\
* packages/eslint-config-airbnb/rules/react.js#L122-L134),
*
* 'react/sort-comp': [2, {
* 'order': [
Expand Down

0 comments on commit 4ca059d

Please sign in to comment.