Skip to content

Commit

Permalink
Merge pull request #3 from alisnic/fix/no-fibers-future-import
Browse files Browse the repository at this point in the history
Fix fibers/future import check
  • Loading branch information
filipenevola committed Feb 20, 2024
2 parents 05667aa + ffa81dd commit 5910824
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/rules/no-fibers-future-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ const isUsingFibersMethods = (node) => {
};

const includesFibersOrFuturePath = (toTest) => toTest &&
typeof toTest === "string" &&
["fibers", "future"].some((t) => toTest.toLowerCase().includes(t));
typeof toTest === "string" && toTest.toLowerCase().startsWith('fibers')

const isImportingFibersOrFuture = (node) => {
const isImportDeclaration = node &&
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"rule": "node scripts/new-rule.js",
"test": "npm run unit-test && npm run coverage:report && npm run coverage:check",
"unit-test": "nyc --reporter=lcov mocha tests --recursive",
"unit-test:watch": "npm run unit-test -s -- --watch -g no-sync-mongo-methods-on-server"
"unit-test:watch": "npm run unit-test -s -- --watch"
},
"files": [
"README.md",
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/no-fibers-future-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ruleTester.run('no-fibers-future-usage', rule, {
{ code: 'const aa = new Test()' },
{ code: 'Testing(function() {})' },
{ code: 'User.current' },
{ code: "import isFuture from 'date-fns/isFuture'" }
],

invalid: [
Expand All @@ -32,6 +33,12 @@ ruleTester.run('no-fibers-future-usage', rule, {
{ message: 'Invalid import/require of Fibers/Future', type: 'ImportDeclaration' },
],
},
{
code: 'import Fibers from "fibers"',
errors: [
{ message: 'Invalid import/require of Fibers/Future', type: 'ImportDeclaration' },
],
},
{
code: 'require("fibers/future")',
errors: [
Expand Down

0 comments on commit 5910824

Please sign in to comment.