-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix false-positive in no-ambiguity-target, fixes #133
- Loading branch information
1 parent
ef09732
commit e0ac240
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
rules/no-ambiguity-target/examples/correct-example-issue-133.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Examples were found in production code-base with exception on 0.10.3 | ||
// https://github.com/igorkamyshev/eslint-plugin-effector/issues/133 | ||
|
||
import { createStore, createEvent, sample } from "effector"; | ||
|
||
const obj = { | ||
fn: () => { | ||
const $store = createStore(0); | ||
const event = createEvent(); | ||
// warning Method `sample` returns `target` and assigns the result to a variable. Consider removing one of them effector/no-ambiguity-target | ||
sample({ | ||
source: event, | ||
target: $store, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { RuleTester } = require("eslint"); | ||
const { join } = require("path"); | ||
|
||
const { readExample } = require("../../utils/read-example"); | ||
const rule = require("./no-ambiguity-target"); | ||
|
||
const ruleTester = new RuleTester({ | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: "module", | ||
}, | ||
}); | ||
|
||
const readExampleForTheRule = (name) => ({ | ||
code: readExample(__dirname, name), | ||
filename: join(__dirname, "examples", name), | ||
}); | ||
|
||
ruleTester.run("effector/no-ambiguity-target.js.test", rule, { | ||
valid: ["correct-example-issue-133.js"].map(readExampleForTheRule), | ||
|
||
invalid: [], | ||
}); |