eslint-plugin-jest
Advanced tools
Comparing version 21.12.1 to 21.12.2
{ | ||
"name": "eslint-plugin-jest", | ||
"version": "21.12.1", | ||
"version": "21.12.2", | ||
"description": "Eslint rules for Jest", | ||
@@ -46,2 +46,3 @@ "repository": "jest-community/eslint-plugin-jest", | ||
"jest": "^22.0.4", | ||
"jest-runner-eslint": "^0.4.0", | ||
"lint-staged": "^6.0.0", | ||
@@ -69,3 +70,23 @@ "prettier": "^1.10.2", | ||
"jest": { | ||
"testEnvironment": "node" | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 96, | ||
"functions": 97, | ||
"lines": 99, | ||
"statements": 99 | ||
} | ||
}, | ||
"projects": [ | ||
{ | ||
"displayName": "test", | ||
"testEnvironment": "node" | ||
}, | ||
{ | ||
"displayName": "lint", | ||
"runner": "jest-runner-eslint", | ||
"testMatch": [ | ||
"<rootDir>/**/*.js" | ||
] | ||
} | ||
] | ||
}, | ||
@@ -72,0 +93,0 @@ "commitlint": { |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../consistent-test-it'); | ||
const ruleTester = new RuleTester({ | ||
@@ -11,3 +12,3 @@ parserOptions: { | ||
ruleTester.run('consistent-test-it with fn=test', rules['consistent-test-it'], { | ||
ruleTester.run('consistent-test-it with fn=test', rule, { | ||
valid: [ | ||
@@ -77,3 +78,3 @@ { | ||
ruleTester.run('consistent-test-it with fn=it', rules['consistent-test-it'], { | ||
ruleTester.run('consistent-test-it with fn=it', rule, { | ||
valid: [ | ||
@@ -141,131 +142,123 @@ { | ||
ruleTester.run( | ||
'consistent-test-it with fn=test and withinDescribe=it ', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'test.only("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'test.skip("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'xtest("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: '[1,2,3].forEach(() => { test("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test.only("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it.only("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { xtest("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { xit("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test.skip("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it.skip("foo") })', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it with fn=test and withinDescribe=it ', rule, { | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'test.only("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'test.skip("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'xtest("foo")', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: '[1,2,3].forEach(() => { test("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test.only("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it.only("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { xtest("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { xit("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test.skip("foo") })', | ||
options: [{ fn: 'test', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it.skip("foo") })', | ||
}, | ||
], | ||
}); | ||
ruleTester.run( | ||
'consistent-test-it with fn=it and withinDescribe=test ', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'it.only("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'it.skip("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'xit("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: '[1,2,3].forEach(() => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it.only("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test.only("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { xit("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { xtest("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it.skip("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test.skip("foo") })', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it with fn=it and withinDescribe=test ', rule, { | ||
valid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'it.only("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'it.skip("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'xit("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: '[1,2,3].forEach(() => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it.only("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test.only("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { xit("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { xtest("foo") })', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it.skip("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test.skip("foo") })', | ||
}, | ||
], | ||
}); | ||
ruleTester.run( | ||
'consistent-test-it with fn=test and withinDescribe=test ', | ||
rules['consistent-test-it'], | ||
rule, | ||
{ | ||
@@ -301,120 +294,104 @@ valid: [ | ||
ruleTester.run( | ||
'consistent-test-it with fn=it and withinDescribe=it ', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'it("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
{ | ||
code: 'test("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
errors: [{ message: "Prefer using 'it' instead of 'test'" }], | ||
output: 'it("foo")', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it with fn=it and withinDescribe=it ', rule, { | ||
valid: [ | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'it("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
{ | ||
code: 'test("foo")', | ||
options: [{ fn: 'it', withinDescribe: 'it' }], | ||
errors: [{ message: "Prefer using 'it' instead of 'test'" }], | ||
output: 'it("foo")', | ||
}, | ||
], | ||
}); | ||
ruleTester.run( | ||
'consistent-test-it defaults without config object', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it defaults without config object', rule, { | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
], | ||
}); | ||
ruleTester.run( | ||
'consistent-test-it with withinDescribe=it', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ withinDescribe: 'it' }], | ||
errors: [{ message: "Prefer using 'test' instead of 'it'" }], | ||
output: 'test("foo")', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it with withinDescribe=it', rule, { | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ withinDescribe: 'it' }], | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ withinDescribe: 'it' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ withinDescribe: 'it' }], | ||
errors: [{ message: "Prefer using 'test' instead of 'it'" }], | ||
output: 'test("foo")', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ withinDescribe: 'it' }], | ||
errors: [ | ||
{ message: "Prefer using 'it' instead of 'test' within describe" }, | ||
], | ||
output: 'describe("suite", () => { it("foo") })', | ||
}, | ||
], | ||
}); | ||
ruleTester.run( | ||
'consistent-test-it with withinDescribe=test', | ||
rules['consistent-test-it'], | ||
{ | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ withinDescribe: 'test' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ withinDescribe: 'test' }], | ||
errors: [{ message: "Prefer using 'test' instead of 'it'" }], | ||
output: 'test("foo")', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test("foo") })', | ||
}, | ||
], | ||
} | ||
); | ||
ruleTester.run('consistent-test-it with withinDescribe=test', rule, { | ||
valid: [ | ||
{ | ||
code: 'test("foo")', | ||
options: [{ withinDescribe: 'test' }], | ||
}, | ||
{ | ||
code: 'describe("suite", () => { test("foo") })', | ||
options: [{ withinDescribe: 'test' }], | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: 'it("foo")', | ||
options: [{ withinDescribe: 'test' }], | ||
errors: [{ message: "Prefer using 'test' instead of 'it'" }], | ||
output: 'test("foo")', | ||
}, | ||
{ | ||
code: 'describe("suite", () => { it("foo") })', | ||
options: [{ withinDescribe: 'test' }], | ||
errors: [ | ||
{ message: "Prefer using 'test' instead of 'it' within describe" }, | ||
], | ||
output: 'describe("suite", () => { test("foo") })', | ||
}, | ||
], | ||
}); |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../lowercase-name'); | ||
@@ -12,3 +12,3 @@ const ruleTester = new RuleTester({ | ||
ruleTester.run('lowercase-name', rules['lowercase-name'], { | ||
ruleTester.run('lowercase-name', rule, { | ||
valid: [ | ||
@@ -15,0 +15,0 @@ "it(' ', function () {})", |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../no-disabled-tests'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('no-disabled-tests', rules['no-disabled-tests'], { | ||
ruleTester.run('no-disabled-tests', rule, { | ||
valid: [ | ||
@@ -18,2 +18,4 @@ 'describe("foo", function () {})', | ||
'var calledSkip = it.skip; calledSkip.call(it)', | ||
'({ f: function () {} }).f()', | ||
'(a || b).f()', | ||
], | ||
@@ -85,2 +87,6 @@ | ||
{ | ||
code: 'pending();', | ||
errors: [{ message: 'Call to pending()', column: 1, line: 1 }], | ||
}, | ||
{ | ||
code: 'describe("contains a call to pending", function () { pending() })', | ||
@@ -87,0 +93,0 @@ errors: [ |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../no-focused-tests'); | ||
@@ -9,3 +9,3 @@ const ruleTester = new RuleTester(); | ||
ruleTester.run('no-focused-tests', rules['no-focused-tests'], { | ||
ruleTester.run('no-focused-tests', rule, { | ||
valid: [ | ||
@@ -12,0 +12,0 @@ 'describe()', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../no-hooks'); | ||
const ruleTester = new RuleTester({ | ||
@@ -11,3 +12,3 @@ parserOptions: { | ||
ruleTester.run('no-hooks', rules['no-hooks'], { | ||
ruleTester.run('no-hooks', rule, { | ||
valid: [ | ||
@@ -14,0 +15,0 @@ 'test("foo")', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../no-identical-title'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('no-identical-title', rules['no-identical-title'], { | ||
ruleTester.run('no-identical-title', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ [ |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../no-test-prefixes'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('no-test-prefixes', rules['no-test-prefixes'], { | ||
ruleTester.run('no-test-prefixes', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ 'describe("foo", function () {})', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../prefer-expect-assertions'); | ||
@@ -15,3 +15,3 @@ const ruleTester = new RuleTester({ | ||
ruleTester.run('prefer-expect-assertions', rules['prefer-expect-assertions'], { | ||
ruleTester.run('prefer-expect-assertions', rule, { | ||
invalid: [ | ||
@@ -18,0 +18,0 @@ { |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../../').rules; | ||
const rule = require('../prefer-to-be-null'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('prefer_to_be_null', rules['prefer-to-be-null'], { | ||
ruleTester.run('prefer-to-be-null', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ 'expect(null).toBeNull();', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../../').rules; | ||
const rule = require('../prefer-to-be-undefined'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('prefer_to_be_undefined', rules['prefer-to-be-undefined'], { | ||
ruleTester.run('prefer-to-be-undefined', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ 'expect(undefined).toBeUndefined();', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../prefer-to-have-length'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('prefer_to_have_length', rules['prefer-to-have-length'], { | ||
ruleTester.run('prefer-to-have-length', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ 'expect(files).toHaveLength(1);', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../valid-describe'); | ||
@@ -12,3 +12,3 @@ const ruleTester = new RuleTester({ | ||
ruleTester.run('valid-describe', rules['valid-describe'], { | ||
ruleTester.run('valid-describe', rule, { | ||
valid: [ | ||
@@ -15,0 +15,0 @@ 'describe("foo", function() {})', |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../valid-expect-in-promise'); | ||
@@ -15,3 +15,3 @@ const ruleTester = new RuleTester({ | ||
ruleTester.run('valid-expect-in-promise', rules['valid-expect-in-promise'], { | ||
ruleTester.run('valid-expect-in-promise', rule, { | ||
invalid: [ | ||
@@ -18,0 +18,0 @@ { |
'use strict'; | ||
const RuleTester = require('eslint').RuleTester; | ||
const rules = require('../..').rules; | ||
const rule = require('../valid-expect'); | ||
const ruleTester = new RuleTester(); | ||
ruleTester.run('valid-expect', rules['valid-expect'], { | ||
ruleTester.run('valid-expect', rule, { | ||
valid: [ | ||
@@ -10,0 +10,0 @@ 'expect("something").toEqual("else");', |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const getNodeName = require('./util').getNodeName; | ||
@@ -10,4 +11,3 @@ const isTestCase = require('./util').isTestCase; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/consistent-test-it.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -14,0 +14,0 @@ fixable: 'code', |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const isItTestOrDescribeFunction = node => { | ||
@@ -51,4 +53,3 @@ return ( | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/lowercase-name.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -65,3 +66,3 @@ }, | ||
data: { method: erroneousMethod }, | ||
node: node, | ||
node, | ||
}); | ||
@@ -68,0 +69,0 @@ } |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
function getName(node) { | ||
function joinNames(a, b) { | ||
return a && b ? a + '.' + b : null; | ||
return a && b ? `${a}.${b}` : null; | ||
} | ||
@@ -23,4 +25,3 @@ | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-disabled-tests.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -33,3 +34,3 @@ }, | ||
return { | ||
CallExpression: node => { | ||
CallExpression(node) { | ||
const functionName = getName(node.callee); | ||
@@ -73,2 +74,7 @@ | ||
}); | ||
} else { | ||
context.report({ | ||
message: 'Call to pending()', | ||
node, | ||
}); | ||
} | ||
@@ -88,3 +94,3 @@ break; | ||
'CallExpression:exit': node => { | ||
'CallExpression:exit'(node) { | ||
const functionName = getName(node.callee); | ||
@@ -91,0 +97,0 @@ |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const testFunctions = Object.assign(Object.create(null), { | ||
@@ -23,4 +25,3 @@ describe: true, | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-focused-tests.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -27,0 +28,0 @@ }, |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
module.exports = { | ||
meta: { | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-hooks.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -9,0 +10,0 @@ }, |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const isDescribe = require('./util').isDescribe; | ||
@@ -42,4 +43,3 @@ const isTestCase = require('./util').isTestCase; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-identical-title.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -46,0 +46,0 @@ }, |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
module.exports = { | ||
meta: { | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-large-snapshots.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -16,3 +17,3 @@ }, | ||
return { | ||
ExpressionStatement: node => { | ||
ExpressionStatement(node) { | ||
const startLine = node.loc.start.line; | ||
@@ -19,0 +20,0 @@ const endLine = node.loc.end.line; |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const getNodeName = require('./util').getNodeName; | ||
@@ -10,4 +11,3 @@ const isTestCase = require('./util').isTestCase; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/no-test-prefixes.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -18,3 +18,3 @@ fixable: 'code', | ||
return { | ||
CallExpression: node => { | ||
CallExpression(node) { | ||
const nodeName = getNodeName(node.callee); | ||
@@ -45,8 +45,8 @@ | ||
if (firstChar === 'f') { | ||
return nodeName.slice(1) + '.only'; | ||
return `${nodeName.slice(1)}.only`; | ||
} | ||
if (firstChar === 'x') { | ||
return nodeName.slice(1) + '.skip'; | ||
return `${nodeName.slice(1)}.skip`; | ||
} | ||
} |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const ruleMsg = | ||
@@ -66,4 +68,3 @@ 'Every test should have either `expect.assertions(<number of assertions>)` or `expect.hasAssertions()` as its first expression'; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/prefer-expect-assertions.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -70,0 +71,0 @@ }, |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const argument = require('./util').argument; | ||
@@ -14,4 +16,3 @@ const argument2 = require('./util').argument2; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/prefer-to-be-null.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -18,0 +19,0 @@ fixable: 'code', |
@@ -8,2 +8,3 @@ 'use strict'; | ||
const expectNotToEqualCase = require('./util').expectNotToEqualCase; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const method = require('./util').method; | ||
@@ -15,4 +16,3 @@ const method2 = require('./util').method2; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/prefer-to-be-undefined.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -19,0 +19,0 @@ fixable: 'code', |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const expectCase = require('./util').expectCase; | ||
@@ -11,4 +13,3 @@ const expectNotCase = require('./util').expectNotCase; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/prefer-to-have-length.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -15,0 +16,0 @@ fixable: 'code', |
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const pkg = require('../package.json'); | ||
const REPO_URL = 'https://github.com/jest-community/eslint-plugin-jest'; | ||
const expectCase = node => | ||
@@ -105,3 +111,3 @@ node.callee.name === 'expect' && | ||
if (node.type === 'MemberExpression') { | ||
return node.object.name + '.' + node.property.name; | ||
return `${node.object.name}.${node.property.name}`; | ||
} | ||
@@ -122,21 +128,43 @@ return node.name; | ||
/** | ||
* Generates the URL to documentation for the given rule name. It uses the | ||
* package version to build the link to a tagged version of the | ||
* documentation file. | ||
* | ||
* @param {string} filename - Name of the eslint rule | ||
* @returns {string} URL to the documentation for the given rule | ||
* @throws {Error} If the documentation file for the given rule is not present. | ||
*/ | ||
const getDocsUrl = filename => { | ||
const ruleName = path.basename(filename, '.js'); | ||
const docsFile = path.join(__dirname, `../docs/rules/${ruleName}.md`); | ||
// istanbul ignore if | ||
if (!fs.existsSync(docsFile)) { | ||
throw new Error(`Could not find documentation file for rule "${ruleName}"`); | ||
} | ||
return `${REPO_URL}/blob/v${pkg.version}/docs/rules/${ruleName}.md`; | ||
}; | ||
module.exports = { | ||
method: method, | ||
method2: method2, | ||
argument: argument, | ||
argument2: argument2, | ||
expectCase: expectCase, | ||
expectNotCase: expectNotCase, | ||
expectResolveCase: expectResolveCase, | ||
expectRejectCase: expectRejectCase, | ||
expectToBeCase: expectToBeCase, | ||
expectNotToBeCase: expectNotToBeCase, | ||
expectToEqualCase: expectToEqualCase, | ||
expectNotToEqualCase: expectNotToEqualCase, | ||
expectToBeUndefinedCase: expectToBeUndefinedCase, | ||
expectNotToBeUndefinedCase: expectNotToBeUndefinedCase, | ||
getNodeName: getNodeName, | ||
isDescribe: isDescribe, | ||
isFunction: isFunction, | ||
isTestCase: isTestCase, | ||
method, | ||
method2, | ||
argument, | ||
argument2, | ||
expectCase, | ||
expectNotCase, | ||
expectResolveCase, | ||
expectRejectCase, | ||
expectToBeCase, | ||
expectNotToBeCase, | ||
expectToEqualCase, | ||
expectNotToEqualCase, | ||
expectToBeUndefinedCase, | ||
expectNotToBeUndefinedCase, | ||
getNodeName, | ||
isDescribe, | ||
isFunction, | ||
isTestCase, | ||
getDocsUrl, | ||
}; |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const isDescribe = require('./util').isDescribe; | ||
@@ -32,4 +33,3 @@ const isFunction = require('./util').isFunction; | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/valid-describe.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -72,3 +72,3 @@ }, | ||
message: 'Unexpected return statement in describe callback', | ||
node: node, | ||
node, | ||
}); | ||
@@ -75,0 +75,0 @@ } |
'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const isFunction = require('./util').isFunction; | ||
@@ -130,4 +131,3 @@ | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/valid-expect-in-promise.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -134,0 +134,0 @@ }, |
@@ -8,2 +8,4 @@ 'use strict'; | ||
const getDocsUrl = require('./util').getDocsUrl; | ||
const expectProperties = ['not', 'resolves', 'rejects']; | ||
@@ -14,4 +16,3 @@ | ||
docs: { | ||
url: | ||
'https://github.com/jest-community/eslint-plugin-jest/blob/master/docs/rules/valid-expect.md', | ||
url: getDocsUrl(__filename), | ||
}, | ||
@@ -18,0 +19,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3307
118333
15
2