Skip to content

Commit

Permalink
Bug fix and patch-version bump (#4)
Browse files Browse the repository at this point in the history
* bump version to 1.1.0

* fix and test for multiple prop fails on one component

* don't handle high counts at all for now, and bump to v1.1.1
  • Loading branch information
sheminusminus authored Mar 25, 2020
1 parent a5e2b27 commit ecab013
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rules/default-props-prefer-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = {

for (
let i = 0, len = expectations.length;
errorMessageId === undefined, i < len; // break the loop on first issue found
errorMessageId === undefined && i < len; // break the loop on first issue found
i += 1
) {
const { value, isOn } = expectations[i];
Expand Down
3 changes: 1 addition & 2 deletions lib/rules/exports-newlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ module.exports = {
const lineDifference = getLineDifference(node, nextNode);

const countIsLow = lineDifference < EXPECTED_LINE_DIFFERENCE;
const countIsHigh = lineDifference > EXPECTED_LINE_DIFFERENCE;

if (countIsLow || countIsHigh) {
if (countIsLow) {
let column = node.loc.start.column;

if (node.loc.start.line !== node.loc.end.line) {
Expand Down
38 changes: 38 additions & 0 deletions lib/tests/rules/default-props-prefer-undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const rule = require('../../rules/default-props-prefer-undefined');

const ERR_MSG_EXPECTED_NOT_NULL = 'Expected default prop someProp to be undefined but is null';
const ERR_MSG_EXPECTED_NOT_FALSE = 'Expected default prop someProp to be undefined but is false';
const ERR_MSG_MULTI_EXPECTED_NOT_NULL = 'Expected default prop anotherProp to be undefined but is null';
const ERR_MSG_MULTI_EXPECTED_NOT_FALSE = 'Expected default prop otherProp to be undefined but is false';

//------------------------------------------------------------------------------
// Tests
Expand Down Expand Up @@ -489,5 +491,41 @@ errors: [{
message: ERR_MSG_EXPECTED_NOT_FALSE,
}],
},
// check that every default prop with issue fires a report
{
code: `
const SomeComponent = (props) => {
return <div />;
};
SomeComponent.propTypes = {
someProp: PropTypes.string,
otherProp: PropTypes.bool,
anotherProp: PropTypes.number,
lastProp: PropTypes.shape({}),
};
SomeComponent.defaultProps = {
someProp: null,
otherProp: false,
anotherProp: null,
lastProp: undefined,
};
`,
options: [{
forbidFalse: true,
}],
errors: [{
line: 12,
column: 11,
message: ERR_MSG_EXPECTED_NOT_NULL,
}, {
line: 13,
column: 11,
message: ERR_MSG_MULTI_EXPECTED_NOT_FALSE,
}, {
line: 14,
column: 11,
message: ERR_MSG_MULTI_EXPECTED_NOT_NULL,
}],
},
],
});
1 change: 1 addition & 0 deletions lib/typedefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @property {*[]} decorators
* @property {Object} loc
* @property {ASTNode} parent
* @property {number[]} range
* @property {string} type
* @property {ASTNode|BuiltInType} value
*/
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-routable",
"version": "1.1.0",
"version": "1.1.1",
"description": "Internal ESLint plugin for Routable",
"keywords": [
"eslint",
Expand Down

0 comments on commit ecab013

Please sign in to comment.