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

ESLint v9 compatibility (TypeError: context.getScope is not a function) #144

Closed
1 task
Tracked by #1175
rivajunior opened this issue Apr 6, 2024 · 8 comments · Fixed by #145
Closed
1 task
Tracked by #1175

ESLint v9 compatibility (TypeError: context.getScope is not a function) #144

rivajunior opened this issue Apr 6, 2024 · 8 comments · Fixed by #145
Assignees
Labels

Comments

@rivajunior
Copy link

What version of eslint-plugin-security are you using?

2.1.1

ESLint Environment

Node version: v20.12.1
npm version: 10.5.0
Local ESLint version: v9.0.0
Global ESLint version: -
Operating System: MacOS 14.4.1

What parser are you using?

@typescript-eslint/parser

What did you do?

Configuration
<!-- Paste your configuration here -->
<!-- Paste your code here -->

What did you expect to happen?

I expected the lint to run without errors

What actually happened?

Oops! Something went wrong! :(

ESLint: 9.0.0

TypeError: context.getScope is not a function
Occurred while linting /my/project/path/banner.ts:13
Rule: "security/detect-child-process"
    at CallExpression (/my/project/path/node_modules/eslint-plugin-security/rules/detect-child-process.js:49:28)
    at ruleErrorHandler (/my/project/path/node_modules/eslint/lib/linter/linter.js:1145:48)
    at /my/project/path/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/my/project/path/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/my/project/path/node_modules/eslint/lib/linter/node-event-generator.js:297:26)
    at NodeEventGenerator.applySelectors (/my/project/path/node_modules/eslint/lib/linter/node-event-generator.js:326:22)
    at NodeEventGenerator.enterNode (/my/project/path/node_modules/eslint/lib/linter/node-event-generator.js:340:14)
    at runRules (/my/project/path/node_modules/eslint/lib/linter/linter.js:1184:40)
    at Linter._verifyWithFlatConfigArrayAndWithoutProcessors (/my/project/path/node_modules/eslint/lib/linter/linter.js:1910:31)

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@rivajunior rivajunior added the bug label Apr 6, 2024
@voxpelli voxpelli changed the title Bug: (TypeError: context.getScope is not a function) ESLint v9 compatibility ESLint v9 compatibility (TypeError: context.getScope is not a function) Apr 6, 2024
@nzakas
Copy link
Contributor

nzakas commented Apr 8, 2024

Thanks for the report, I'll take a look.

@dmitriyrotaenko
Copy link

The problem is still alive in eslint ^9.2.0. Should I open another issue?

@aladdin-add
Copy link
Contributor

@dmitriyrotaenko please file a new issue with a repro, thanks! 🙏

@AlwaysLoveme
Copy link

The problem is still alive in eslint ^9.2.0. Should I open another issue?

same here:

eslint.config.js:

// @ts-check

import globals from "globals";
import pluginJs from "@eslint/js";
import tsLint from "typescript-eslint";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";


export default tsLint.config(
		{
			languageOptions: {
				globals: {...globals.browser, ...globals.node}
			}
		},
		pluginJs.configs.recommended,
		...tsLint.configs.recommended,
		pluginReactConfig,
		{
			plugins: ["react", 'react-refresh'],
			files: ["**/*.tsx", "**/*.ts"],
			rules: {
				'react/require-render-return': 'off',
				'react-refresh/only-export-components': [
					'warn',
					{allowConstantExport: true},
				],
				"@typescript-eslint/ban-ts-comment": "off",
				"@typescript-eslint/no-explicit-any": "off",
				"@typescript-eslint/no-unused-vars": "off",
				"@typescript-eslint/no-var-requires": "off",
				"semi": ["error", "always"], // 强制末尾分号
				"quotes": ["error", "double", {allowTemplateLiterals: true}],
				"@next/next/no-img-element": "off",
				"eqeqeq": "error", // 要求使用 === 和 !==
				"no-empty": "error", // 块语句中的内容不能为空
				"no-empty-character-class": "error", // 正则表达式中的[]内容不能为空
				"no-extra-boolean-cast": "error", // 禁止不必要的bool转换
				"no-extra-parens": "off", // 禁止非必要的括号
				"no-extra-semi": "error", // 禁止多余的冒号
				"no-invalid-this": "error", // 禁止无效的this,只能用在构造器,类,对象字面量
				"no-irregular-whitespace": "error", // 不能有不规则的空格
				"no-self-assign": "error", // 禁止自我赋值
				"no-self-compare": "error", // 禁止自身比较
				"no-sequences": "error", // 禁用逗号操作符
				"key-spacing": ["error", {beforeColon: false, afterColon: true}], // 对象字面量中冒号的前后空格
				"no-unmodified-loop-condition": "error", // 禁用一成不变的循环条件
				"no-unused-expressions": "off", // 禁止出现未使用过的表达式
				"object-curly-spacing": ["error", "always"], // 对象前后需要空格
				"array-bracket-spacing": [
					"error",
					"never",
					{
						objectsInArrays: false,
					},
				], // 是否允许非空数组里面有多余的空格
				"arrow-parens": "off", // 箭头函数用小括号括起来
				"block-spacing": ["error", "always"], // =>的前/后括号
				"callback-return": "off", // 避免多次调用回调
				"react/self-closing-comp": [
					"error",
					{
						component: true,
						html: false,
					},
				],
				"react/react-in-jsx-scope": "off",
				"react/jsx-closing-tag-location": ["error"],
				"react/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
				"react/jsx-closing-bracket-location": ["error"],
				"react/jsx-max-props-per-line": ["error", {maximum: 1, when: "always"}],
				"react/jsx-wrap-multilines": [
					"error",
					{
						declaration: true,
						assignment: true,
						return: true,
						arrow: true,
						condition: true,
					},
				],
				"react/jsx-sort-props": [
					"error",
					{
						multiline: "last",
						callbacksLast: true,
						shorthandFirst: true,
					},
				],
				'react/jsx-no-undef': ['error', {allowGlobals: true}],
				"react-hooks/exhaustive-deps": ["off"],
			}
		}
);

@nzakas
Copy link
Contributor

nzakas commented May 6, 2024

This has nothing to do with the version of ESLint. Please make sure you have upgraded your eslint-plugin-security to latest.

@flowerhahaha
Copy link

I got the same issue, and I didn't use eslint-plugin-security in my project.
I've upgraded all the related packages to the latest and the problem still alive. Any suggestions? Thanks a lot.

@jmaczan
Copy link

jmaczan commented May 7, 2024

I get the same error when running eslint src/**/*.{js,jsx,ts,tsx}

Deps:

    "@eslint/js": "^9.2.0",
    "eslint": "^9.2.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.1.3",
    "eslint-plugin-react": "^7.34.1",

@nzakas
Copy link
Contributor

nzakas commented May 7, 2024

Okay, it seems like people are a bit confused: this repository is only for eslint-plugin-security. If you're not using eslint-plugin-security, then you need to file an issue with the owner of the plugin you're having trouble with.

@eslint-community eslint-community locked as resolved and limited conversation to collaborators May 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants