Skip to content

Crash in unicorn/no-instanceof-builtins and similar rules when linting .vue files #2643

@polis89

Description

@polis89

After upgrading from eslint-plugin-unicorn@56.0.1 to 57.0.0+ I'm experiencing ESLint crashes when linting .vue files with the following error:

Stack Trace
ESLint: 9.26.0

TypeError: Cannot read properties of null (reading 'childScopes')
Occurred while linting ./src/App.vue:14
Rule: "unicorn/explicit-length-check"
    at getInnermostScope (file://./.yarn/__virtual__/@eslint-community-eslint-utils-virtual-d459a613f3/3/.yarn/berry/cache/@eslint-community-eslint-utils-npm-4.7.0-47503bfa2a-10c0.zip/node_modules/@eslint-community/eslint-utils/index.mjs:19:40)
    at findVariable (file://./.yarn/__virtual__/@eslint-community-eslint-utils-virtual-d459a613f3/3/.yarn/berry/cache/@eslint-community-eslint-utils-npm-4.7.0-47503bfa2a-10c0.zip/node_modules/@eslint-community/eslint-utils/index.mjs:54:17)
    at file://./.yarn/__virtual__/eslint-plugin-unicorn-virtual-c66979b7c0/3/.yarn/berry/cache/eslint-plugin-unicorn-npm-59.0.1-5373ae1135-10c0.zip/node_modules/eslint-plugin-unicorn/rules/shared/simple-array-search-rule.js:90:5
    at EventEmitter.<anonymous> (file://./.yarn/__virtual__/eslint-plugin-unicorn-virtual-c66979b7c0/3/.yarn/berry/cache/eslint-plugin-unicorn-npm-59.0.1-5373ae1135-10c0.zip/node_modules/eslint-plugin-unicorn/rules/utils/rule.js:118:31)
    at EventEmitter.emit (node:events:530:35)
    at NodeEventGenerator.applySelector (./.yarn/__virtual__/vue-eslint-parser-virtual-7266f75b02/3/.yarn/berry/cache/vue-eslint-parser-npm-10.1.3-d7a30e8e7b-10c0.zip/node_modules/vue-eslint-parser/index.js:4373:26)
    at NodeEventGenerator.applySelectors (./.yarn/__virtual__/vue-eslint-parser-virtual-7266f75b02/3/.yarn/berry/cache/vue-eslint-parser-npm-10.1.3-d7a30e8e7b-10c0.zip/node_modules/vue-eslint-parser/index.js:4393:22)
    at NodeEventGenerator.enterNode (./.yarn/__virtual__/vue-eslint-parser-virtual-7266f75b02/3/.yarn/berry/cache/vue-eslint-parser-npm-10.1.3-d7a30e8e7b-10c0.zip/node_modules/vue-eslint-parser/index.js:4401:14)
    at traverse (./.yarn/__virtual__/vue-eslint-parser-virtual-7266f75b02/3/.yarn/berry/cache/vue-eslint-parser-npm-10.1.3-d7a30e8e7b-10c0.zip/node_modules/vue-eslint-parser/index.js:169:13)
    at traverse (./.yarn/__virtual__/vue-eslint-parser-virtual-7266f75b02/3/.yarn/berry/cache/vue-eslint-parser-npm-10.1.3-d7a30e8e7b-10c0.zip/node_modules/vue-eslint-parser/index.js:181:13)

At least the following rules are affected:

  • unicorn/no-instanceof-builtins
  • unicorn/number-literal-case
  • unicorn/prefer-array-some
  • unicorn/prefer-includes

Minimal package.json to reproduce:

{
  "name": "test_eslint",
  "packageManager": "yarn@4.6.0",
  "devDependencies": {
    "eslint": "^9.26.0",
    "eslint-plugin-unicorn": "^59.0.0",
    "eslint-plugin-vue": "^10.1.0",
    "vue-eslint-parser": "^10.1.3"
  }
}

and eslint.config.mjs

import unicorn from "eslint-plugin-unicorn";
import vue from "eslint-plugin-vue";

export default [
	unicorn.configs["flat/recommended"],
	...vue.configs["flat/recommended"],
	{
		files: ["**/*.vue"],
		rules: {
			// skipping the following rules fixes the issue
			// "unicorn/no-instanceof-builtins": "off",
			// "unicorn/number-literal-case": "off",
			// "unicorn/prefer-array-some": "off",
			// "unicorn/prefer-includes": "off"
		}
	}
];

I'm able to work around the issue by disabling the above rules for *.vue files, but I'd like to keep them enabled to ensure consistent linting behavior across all files, including Vue SFCs.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy