Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected null when attempting to fix #600

Closed
sshivananda opened this issue May 31, 2020 · 2 comments
Closed

Error: Unexpected null when attempting to fix #600

sshivananda opened this issue May 31, 2020 · 2 comments
Labels

Comments

@sshivananda
Copy link

Seeing the following error while runnint eslint

Oops! Something went wrong! :(

ESLint: 7.1.0

Error: Unexpected null when attempting to fix /Users/sshivananda/git/ts-sqs-consumer/integration-test/step-definitions/processes_all_messages_if_there_is_no_error.steps.ts - please file a github issue at https://github.com/jest-community/eslint-plugin-jest
Occurred while linting /Users/sshivananda/git/ts-sqs-consumer/integration-test/step-definitions/processes_all_messages_if_there_is_no_error.steps.ts:10
    at Object.fix (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint-plugin-jest/lib/rules/no-test-callback.js:75:21)
    at normalizeFixes (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/report-translator.js:178:28)
    at /Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/report-translator.js:343:49
    at Object.report (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/linter.js:917:41)
    at CallExpression (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint-plugin-jest/lib/rules/no-test-callback.js:53:17)
    at /Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (/Users/sshivananda/git/ts-sqs-consumer/node_modules/eslint/lib/linter/node-event-generator.js:283:22)

Here's my eslintrc

module.exports = {
  extends: [
    'airbnb-typescript/base',
    'plugin:jest/recommended',
    'plugin:security/recommended',
  ],
  plugins: [
    '@typescript-eslint',
    'jest',
    'security',
  ],
  parserOptions: {
    project: './tsconfig.json',
  },
  rules: {
    'object-shorthand' : 0,
    'no-await-in-loop': 0,
    // Overriding restricted syntax rule to remove for of from the blacklist
    'no-restricted-syntax': [
      'error',
      {
        selector: 'ForInStatement',
        message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
      },
      {
        selector: 'LabeledStatement',
        message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
      },
      {
        selector: 'WithStatement',
        message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
      },
    ],
  }
};

And the eslint command is run as

eslint -c .eslintrc.js --ext .ts .

This error can be replicated by the repo at https://github.com/sshivananda/ts-sqs-consumer

@G-Rath
Copy link
Collaborator

G-Rath commented May 31, 2020

Cheers for this, it's caused by destructuring - ironically I've already fixed this in #586, but our CI is currently having issues so I've not been able to release anything.

However, no-test-callback actually shouldn't be checking that call since it's not the Jest test variable, which is tracked by #556.

For now I'd recommend disabling the rule for at least that line, or renaming the variable :)

@G-Rath
Copy link
Collaborator

G-Rath commented Jun 21, 2020

Forgot to link this before merging the PR 😬

🎉 This PR is included in version 23.14.0 🎉

The release is available on:

npm package (@latest dist-tag)
GitHub release
Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants