Skip to content

Commit

Permalink
fix(no-allow-react-context): fix expect option
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Sep 8, 2016
1 parent 6ee6e38 commit dec467f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
"power-assert": "^1.4.1"
},
"dependencies": {
"minimatch-all": "^1.1.0"
"minimatch": "^3.0.3"
}
}
8 changes: 5 additions & 3 deletions src/rules/no-allow-react-context.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// LICENSE : MIT
"use strict";
const minimatchAll = require('minimatch-all');
const minimatch = require('minimatch');
const isReactContextClassProperty = (node) => {
return node.type === "ClassProperty" &&
node.static === true &&
Expand All @@ -17,8 +17,10 @@ module.exports = function(context) {
}
// if match except pattern, then ignore this file
if (options && filePath && Array.isArray(options.except)) {
const isIgnoredFile = minimatchAll(filePath, options.except, {
dot: true
const isIgnoredFile = options.except.some(except => {
return minimatch(filePath, except, {
dot: true
})
});
if (isIgnoredFile) {
return {};
Expand Down
19 changes: 19 additions & 0 deletions test/no-allow-react-context-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ tester.run("no-allow-react-context", rule, {
}
]
},
{
code: `class A{ get contextTypes(){} }`,
filename: __dirname + "/test.js",
options: [
{
except: ["**/**/test.js", "**/**/other.js"]
}
]
},
// TODO: fix me
{
code: `class A{ get contextTypes(){} }`,
filename: __dirname + "test/test.js",
options: [
{
except: ["**/**/test.js", "**/**/other.js", "!test/**"]
}
]
}
],
invalid: [
{
Expand Down

0 comments on commit dec467f

Please sign in to comment.