graphql-eslint: Bug: Leading to new Errors while Upgrading package
Describe the bug
Bug: Leading to new Errors while Upgrading package typescript-eslint/eslint-plugin from 5.62.0 to 6.19.0 #8266
this is my .eslintric.json: { “env”: { “es2022”: true, “node”: true }, “extends”: [ “eslint:recommended”, “plugin:@typescript-eslint/recommended”, “prettier” ], “overrides”: [ { “files”: [“./src/typeDefs//*.ts”], “processor”: “@graphql-eslint/graphql” }, { “files”: [“./src/typeDefs//.graphql”], “parser”: “@graphql-eslint/eslint-plugin”, “plugins”: [“@graphql-eslint”], // Do not apply naming conventions to .graphql files “rules”: { “@typescript-eslint/naming-convention”: “off” } }, { “files”: [“tests/**/”], “rules”: { “no-restricted-imports”: “off” } }, { // Disable explicit function return type for index.ts as it uses a lot of templated code // which has convulated return types “files”: [“./src/index.ts”, “./src/utilities/copyToClipboard.ts”], “rules”: { “@typescript-eslint/explicit-function-return-type”: “off”, “@typescript-eslint/no-empty-function”: “off” } } ],
“parser”: “@typescript-eslint/parser”, “parserOptions”: { “project”: “./tsconfig.json”, “tsconfigRootDir”: “.”, “ecmaVersion”: “latest”, “sourceType”: “module” },
“plugins”: [“https://github.com/typescript-eslint”, “eslint-plugin-tsdoc”, “import”], “root”: true, “rules”: { “no-restricted-imports”: [ “error”, { “patterns”: [“/src/”] } ],
// restrict the use of same package in multiple import statements “import/no-duplicates”: “warn”,
// warn/1, error/2, off/0 “tsdoc/syntax”: “warn”,
// Typescript Rules “@typescript-eslint/ban-ts-comment”: “warn”, “@typescript-eslint/no-explicit-any”: “warn”, “@typescript-eslint/no-inferrable-types”: “warn”, “@typescript-eslint/no-non-null-asserted-optional-chain”: “warn”, “@typescript-eslint/no-non-null-assertion”: “warn”, “@typescript-eslint/no-var-requires”: “warn”, “@typescript-eslint/ban-types”: “warn”, “@typescript-eslint/no-duplicate-enum-values”: “warn”,
// Typescript rule to enforce PascalCase naming convention for types and interfaces “@typescript-eslint/naming-convention”: [ “error”, // Interfaces must begin with Interface or TestInterface followed by a PascalCase name { “selector”: “interface”, “format”: [“PascalCase”], “prefix”: [“Interface”, “TestInterface”] }, // Type Aliases must be in PascalCase { “selector”: [“typeAlias”, “typeLike”, “enum”], “format”: [“PascalCase”] }, { “selector”: “typeParameter”, “format”: [“PascalCase”], “prefix”: [“T”] }, { “selector”: “variable”, “format”: [“camelCase”, “UPPER_CASE”], “leadingUnderscore”: “allow” }, { “selector”: “parameter”, “format”: [“camelCase”], “leadingUnderscore”: “allow” }, { “selector”: “function”, “format”: [“camelCase”] }, { “selector”: “memberLike”, “modifiers”: [“private”], “format”: [“camelCase”], “leadingUnderscore”: “require” }, { “selector”: “variable”, “modifiers”: [“exported”], “format”: null } ],
// Typescript additional rules “@typescript-eslint/array-type”: “warn”, “@typescript-eslint/consistent-type-assertions”: “warn”, “@typescript-eslint/consistent-type-imports”: “warn”, “@typescript-eslint/explicit-function-return-type”: “warn” } } Witten override rules to use eslint/graphql-parser for .graphql files but causing this error. NEED YOUR VALUABLE GUIDANCE TO REMOVE THIS ISSUE IN MY PROJECT. My previous version 5.6.2 worked fine with above rules but when now upgrading it leading to this new error:
**>> C:\Users\91970\Desktop\talawa\talawa-api>
talawa-api@1.0.0 lint:check eslint . --max-warnings=1500
Oops! Something went wrong! 😦
ESLint: 8.56.0
Error: Error while loading rule ‘@typescript-eslint/consistent-type-assertions’: You have used a rule which requires parserServices to be generated. You must therefore provide a value for the “parserOptions.project” property for @typescript-eslint/parser. Note: detected a parser other than @typescript-eslint/parser. Make sure the parser is configured to forward “parserOptions.project” to @typescript-eslint/parser. Occurred while linting C:\Users\91970\Desktop\talawa\talawa-api\src\typeDefs\directives.ts\0_document.graphql at throwError (C:\Users\91970\Desktop\talawa\talawa-api\node_modules@typescript-eslint\utils\dist\eslint-utils\getParserServices.js:39:11) at getParserServices (C:\Users\91970\Desktop\talawa\talawa-api\node_modules@typescript-eslint\utils\dist\eslint-utils\getParserServices.js:23:9) at create (C:\Users\91970\Desktop\talawa\talawa-api\node_modules@typescript-eslint\eslint-plugin\dist\rules\consistent-type-assertions.js:90:61) at Object.create (C:\Users\91970\Desktop\talawa\talawa-api\node_modules@typescript-eslint\utils\dist\eslint-utils\RuleCreator.js:38:20) at createRuleListeners (C:\Users\91970\Desktop\talawa\talawa-api\node_modules\eslint\lib\linter\linter.js:895:21) at C:\Users\91970\Desktop\talawa\talawa-api\node_modules\eslint\lib\linter\linter.js:1066:110 at Array.forEach () at runRules (C:\Users\91970\Desktop\talawa\talawa-api\node_modules\eslint\lib\linter\linter.js:1003:34) at Linter._verifyWithoutProcessors (C:\Users\91970\Desktop\talawa\talawa-api\node_modules\eslint\lib\linter\linter.js:1355:31) at Linter._verifyWithConfigArray (C:\Users\91970\Desktop\talawa\talawa-api\node_modules\eslint\lib\linter\linter.js:1807:21)**
To Reproduce Steps to reproduce the behavior: npm install eslint@latest @typescript-eslint/parser@latest @typescript-eslint/eslint-plugin@latest eslint-plugin-tsdoc@latest eslint-plugin-import@latest --save-dev
npm lint:check
Expected behavior
It should override the .graphql files and needs to pase with graphql/eslint-plugin as above without any errors Environment:
- OS: Windows 11
@graphql-eslint/eslint-plugin: 3.20.1- Node.js: 21.1.0
Additional context
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 18 (6 by maintainers)
if you still run typescript/eslint run on graphql files your config is still invalid
@dimaMachina Thanks for your valuable guidance on it. This issue was fixed successfully
@varshith257 Do you think your code comments are readable?
move below outside of top level config in own override object