Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jest-community/eslint-plugin-jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v28.8.0
Choose a base ref
...
head repository: jest-community/eslint-plugin-jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v28.8.1
Choose a head ref
  • 5 commits
  • 5 files changed
  • 4 contributors

Commits on Aug 12, 2024

  1. chore(deps): lock file maintenance

    renovate[bot] committed Aug 12, 2024
    Copy the full SHA
    f5f3e99 View commit details

Commits on Aug 19, 2024

  1. chore(deps): lock file maintenance

    renovate[bot] committed Aug 19, 2024
    Copy the full SHA
    f969f92 View commit details

Commits on Aug 26, 2024

  1. Copy the full SHA
    267702d View commit details

Commits on Aug 29, 2024

  1. fix(prefer-importing-jest-globals): support typescript-eslint parser (#…

    …1639)
    
    * fix(prefer-importing-jest-globals): support new config
    
    * fix(prefer-importing-jest-globals): tests, broken due to types
    
    * fix(prefer-importing-jest-globals): update tests
    
    * fix(prefer-importing-jest-globals): include valid tests
    
    * fix(prefer-importing-jest-globals): split typescript tests
    
    ---------
    
    Co-authored-by: Erin Zimmer <ezimmer@atlassian.com>
    ejzimmer and ezimmer-atlassian authored Aug 29, 2024
    Copy the full SHA
    307f6a7 View commit details
  2. chore(release): 28.8.1 [skip ci]

    ## [28.8.1](v28.8.0...v28.8.1) (2024-08-29)
    
    ### Bug Fixes
    
    * **prefer-importing-jest-globals:** support typescript-eslint parser ([#1639](#1639)) ([307f6a7](307f6a7))
    semantic-release-bot committed Aug 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1df45e9 View commit details
Showing with 310 additions and 194 deletions.
  1. +7 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +58 −0 src/rules/__tests__/prefer-importing-jest-globals.test.ts
  4. +3 −1 src/rules/prefer-importing-jest-globals.ts
  5. +241 −192 yarn.lock
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [28.8.1](https://github.com/jest-community/eslint-plugin-jest/compare/v28.8.0...v28.8.1) (2024-08-29)


### Bug Fixes

* **prefer-importing-jest-globals:** support typescript-eslint parser ([#1639](https://github.com/jest-community/eslint-plugin-jest/issues/1639)) ([307f6a7](https://github.com/jest-community/eslint-plugin-jest/commit/307f6a7b3aad7a5c891d8fea9f115e5d2f4f3fbb))

# [28.8.0](https://github.com/jest-community/eslint-plugin-jest/compare/v28.7.0...v28.8.0) (2024-08-07)


2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-jest",
"version": "28.8.0",
"version": "28.8.1",
"description": "ESLint rules for Jest",
"keywords": [
"eslint",
58 changes: 58 additions & 0 deletions src/rules/__tests__/prefer-importing-jest-globals.test.ts
Original file line number Diff line number Diff line change
@@ -548,3 +548,61 @@ ruleTester.run('prefer-importing-jest-globals', rule, {
},
],
});

new RuleTester({
parser: require.resolve('@typescript-eslint/parser'),
}).run('prefer-importing-jest-globals: typescript edition', rule, {
valid: [],
invalid: [
{
code: dedent`
import describe from '@jest/globals';
describe("suite", () => {
test("foo");
expect(true).toBeDefined();
})
`,
output: dedent`
import { describe, expect, test } from '@jest/globals';
describe("suite", () => {
test("foo");
expect(true).toBeDefined();
})
`,
parserOptions: { sourceType: 'module' },
errors: [
{
endColumn: 7,
column: 3,
line: 3,
messageId: 'preferImportingJestGlobal',
},
],
},
{
code: dedent`
const {describe} = require('@jest/globals');
describe("suite", () => {
test("foo");
expect(true).toBeDefined();
})
`,
output: dedent`
const { describe, expect, test } = require('@jest/globals');
describe("suite", () => {
test("foo");
expect(true).toBeDefined();
})
`,
parserOptions: { sourceType: 'script' },
errors: [
{
endColumn: 7,
column: 3,
line: 3,
messageId: 'preferImportingJestGlobal',
},
],
},
],
});
4 changes: 3 additions & 1 deletion src/rules/prefer-importing-jest-globals.ts
Original file line number Diff line number Diff line change
@@ -94,7 +94,9 @@ export default createRule({
return;
}

const isModule = context.parserOptions.sourceType === 'module';
const isModule =
context.parserOptions.sourceType === 'module' ||
context.languageOptions?.sourceType === 'module';

context.report({
node: reportingNode,
433 changes: 241 additions & 192 deletions yarn.lock

Large diffs are not rendered by default.