-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests using both regular eslint/no-unused-vars and @typescript-es…
…lint/no-unused-vars I also setup a prettier config here and ran it because i didnt think.
- Loading branch information
Showing
14 changed files
with
5,193 additions
and
5,499 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
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,10 @@ | ||
module.exports = { | ||
tabWidth: 4, | ||
semi: true, // Trailing semicolons | ||
trailingComma: "all", | ||
singleQuote: false, | ||
quoteProps: "as-needed", | ||
bracketSpacing: true, | ||
printWidth: 100, // Line width (this fit my 1440p screen at a half-screen window) | ||
arrowParens: "always", | ||
}; |
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 |
---|---|---|
@@ -1,20 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.1.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug current test file", | ||
"runtimeExecutable": "npm", | ||
"runtimeArgs": ["test", "--testPathPattern", "${file}", "--coverage", "false"], | ||
"port": 9229, | ||
"cwd": "${fileDirname}", | ||
"timeout": 10000, | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.1.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Debug current test file", | ||
"runtimeExecutable": "npm", | ||
"runtimeArgs": ["test", "--testPathPattern", "${file}", "--coverage", "false"], | ||
"port": 9229, | ||
"cwd": "${fileDirname}", | ||
"timeout": 10000, | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} | ||
|
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,92 @@ | ||
module.exports = { | ||
valid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
const c = a() + b + x() + y(); | ||
`, | ||
}, | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
const c = b(x, y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import x from "package"; | ||
import { b } from "./utils"; | ||
import y from "package"; | ||
const c = b(x, y); | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
/** | ||
* this is a jsdoc! | ||
*/ | ||
const c = a(y); | ||
`, | ||
errors: ["'b' is defined but never used."], | ||
output: ` | ||
import { a } from "./utils"; | ||
import y from "package"; | ||
/** | ||
* this is a jsdoc! | ||
*/ | ||
const c = a(y); | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
import { a } from "./utils"; | ||
import y from "package"; | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import y from "package"; | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
}, | ||
{ | ||
code: ` | ||
import y from "package"; | ||
import { a } from "./utils"; | ||
/** | ||
* c is the number 4 | ||
*/ | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import y from "package"; | ||
/** | ||
* c is the number 4 | ||
*/ | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
}, | ||
], | ||
}; |
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,53 @@ | ||
RuleTester = require("eslint").RuleTester; | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: require.resolve('@typescript-eslint/parser'), | ||
parserOptions: { | ||
ecmaVersion: 2015, | ||
sourceType: "module", | ||
}, | ||
}); | ||
|
||
const cases = require("./cases"); | ||
|
||
global.eslintUnusedImportsForceLoadJSLint = "false"; | ||
let rule; | ||
jest.isolateModules(() => { | ||
rule = require("../rules/no-unused-imports"); | ||
}); | ||
ruleTester.run("no-unused-imports-js", rule, cases); | ||
ruleTester.run("no-unused-imports-ts", rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
import TType from "Package"; | ||
const c: TType = a() + b + x() + y(); | ||
`, | ||
}, | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
import TType from "Package"; | ||
const c = a() + b + x() + y(); | ||
`, | ||
errors: ["'TType' is defined but never used."], | ||
output: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
const c = a() + b + x() + y(); | ||
`, | ||
}, | ||
], | ||
}); |
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 |
---|---|---|
@@ -1,97 +1,14 @@ | ||
const rule = require("../rules/no-unused-imports"); | ||
RuleTester = require("eslint").RuleTester; | ||
|
||
const ruleTester = new RuleTester({ parserOptions: { ecmaVersion: 2015, sourceType: "module", } }); | ||
const ruleTester = new RuleTester({ | ||
parserOptions: { ecmaVersion: 2015, sourceType: "module" }, | ||
}); | ||
|
||
ruleTester.run("no-unused-imports", rule, { | ||
valid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
const cases = require("./cases"); | ||
|
||
const c = a() + b + x() + y(); | ||
`, | ||
} | ||
], | ||
|
||
invalid: [ | ||
{ | ||
code: ` | ||
import x from "package"; | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
const c = b(x, y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import x from "package"; | ||
import { b } from "./utils"; | ||
import y from "package"; | ||
const c = b(x, y); | ||
` | ||
}, | ||
{ | ||
code: ` | ||
import { a, b } from "./utils"; | ||
import y from "package"; | ||
/** | ||
* this is a jsdoc! | ||
*/ | ||
const c = a(y); | ||
`, | ||
errors: ["'b' is defined but never used."], | ||
output: ` | ||
import { a } from "./utils"; | ||
import y from "package"; | ||
/** | ||
* this is a jsdoc! | ||
*/ | ||
const c = a(y); | ||
` | ||
}, | ||
{ | ||
code: ` | ||
import { a } from "./utils"; | ||
import y from "package"; | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import y from "package"; | ||
const c = 4; | ||
console.log(y); | ||
` | ||
}, | ||
{ | ||
code: ` | ||
import y from "package"; | ||
import { a } from "./utils"; | ||
/** | ||
* c is the number 4 | ||
*/ | ||
const c = 4; | ||
console.log(y); | ||
`, | ||
errors: ["'a' is defined but never used."], | ||
output: ` | ||
import y from "package"; | ||
/** | ||
* c is the number 4 | ||
*/ | ||
const c = 4; | ||
console.log(y); | ||
` | ||
} | ||
] | ||
}); | ||
global.eslintUnusedImportsForceLoadJSLint = "true"; | ||
let rule; | ||
jest.isolateModules(() => { | ||
rule = require("../rules/no-unused-imports"); | ||
}); | ||
ruleTester.run("no-unused-imports", rule, cases); |
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
Oops, something went wrong.