-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8b2dd9
commit 411af62
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
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,42 @@ | ||
import { test, testFilePath } from '../utils' | ||
|
||
import { RuleTester } from 'eslint' | ||
|
||
const ruleTester = new RuleTester() | ||
, rule = require('rules/no-self-import') | ||
|
||
const error = { | ||
ruleId: 'no-self-import', | ||
message: 'Module imports itself', | ||
} | ||
|
||
ruleTester.run('no-self-import', rule, { | ||
valid: [ | ||
test({ code: 'import _ from "lodash"'}), | ||
test({ code: 'import find from "lodash.find"'}), | ||
test({ code: 'import foo from "./foo"'}), | ||
test({ code: 'import foo from "../foo"'}), | ||
test({ code: 'import foo from "foo"'}), | ||
test({ code: 'import foo from "./"'}), | ||
test({ code: 'import foo from "@scope/foo"'}), | ||
test({ code: 'var _ = require("lodash")'}), | ||
test({ code: 'var find = require("lodash.find")'}), | ||
test({ code: 'var foo = require("./foo")'}), | ||
test({ code: 'var foo = require("../foo")'}), | ||
test({ code: 'var foo = require("foo")'}), | ||
test({ code: 'var foo = require("./")'}), | ||
test({ code: 'var foo = require("@scope/foo")'}), | ||
], | ||
invalid: [ | ||
test({ | ||
code: 'import bar from "./bar"', | ||
errors: [error], | ||
filename: testFilePath('./bar.js'), | ||
}), | ||
test({ | ||
code: 'var bar = require("./bar")', | ||
errors: [error], | ||
filename: testFilePath('./bar.js'), | ||
}), | ||
], | ||
}) |