@aws-appsync/eslint-plugin not compatible with eslint v9
When trying to to use @aws-appsync/eslint-plugin with eslint v9 I get the following error message:
TypeError: Error while loading rule '@graphql-eslint/no-unreachable-types': Cannot destructure property 'schema' of 'context.parserServices' as it is undefined.
I suspsect that this is due to that the plugin has not been updated for eslint v9: https://eslint.org/blog/2023/09/preparing-custom-rules-eslint-v9/#from-context-to-sourcecode
Is this potentially related? looks like a dependency conflict
$ npm i @typescript-eslint/[email protected] --save-dev
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: [email protected]
npm error Found: @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/parser
npm error @typescript-eslint/parser@"^6.6.0" from @aws-appsync/[email protected]
npm error node_modules/@aws-appsync/eslint-plugin
npm error dev @aws-appsync/eslint-plugin@"^1.6.0" from the root project
npm error
npm error Could not resolve dependency:
npm error dev @typescript-eslint/eslint-plugin@"5.0.0" from the root project
npm error
npm error Conflicting peer dependency: @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/parser
npm error peer @typescript-eslint/parser@"^5.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"5.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
bump.
Can someone help me understand? does AWS actively demand people code in the gui???
I'm facing the same issue
I must prefix this with: I do not understand how to configure ESLint. With a bunch of trial/error/copy&paste I ended up with this
import tseslint from "typescript-eslint";
import { fixupConfigRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
const flatCompat = new FlatCompat();
export default tseslint.config(
{
files: ["**/*.{ts}"],
},
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
files: ["**/*.{js,mjs}"],
extends: [tseslint.configs.disableTypeChecked],
},
{
languageOptions: {
parserOptions: {
project: true,
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
...fixupConfigRules(
flatCompat.extends("plugin:@aws-appsync/recommended")
).map((config) => ({
...config,
files: ["**/resolvers/**/*.ts"],
})),
{ ignores: ["eslint.config.mjs", "jest.config.js"] }
);
Which appears to be working. It will lint anything in /resolvers/ as an appsync resolver.
@osadi, I tried your solution, but I could not get it working. (I am no eslint expert either.) Are you using eslint v9? What other package versions are you using?
Yeah sorry, me neither actually. It was working, but coming back to it now I just get an OOM from eslint so somethings not right.
Can we please get this sorted? It seems that the repo (https://github.com/aws/aws-appsync-toolkit) is private so we can't even make a PR.
plus one. Thank you @EHadoux I was looking for the repo housing the code for the @aws-appsync/eslint-plugin npm module. Sad that it is private. NPM believes it is licensed under the apache license. It somewhat saps morale to need to modify the plugin only for one's self, though.
I'm also using TypeScript. The instructions for the @aws-appsync/eslint-plugin still expect the old eslintrc.json format associated with eslint v8, and has outdated references to @typescript-eslint/parser which seems to be outdated as well; it is no longer referenced directly at all for the eslint v9 flat-file configuration instructions for typescript-eslint.
This @aws-appsync/eslint-plugin is very valuable to me. It has helped me tremendously in development of my mapping templates in the JS appsync runtime. However, the time has come for me to migrate to eslint 9 and the flat file configuration. Such a shame that AWS AppSync hasn't updated the plugin and keeps the plugin repo private.
+1
+1
+1
v2.0.1 of the @aws-appsync/eslint-plugin was released some days ago and I managed to get it working with eslint v9.18.0 https://www.npmjs.com/package/@aws-appsync/eslint-plugin/v/2.0.1
Confirmed. I was able to do the same with V2.
Thanks!