aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

@aws-appsync/eslint-plugin not compatible with eslint v9 #369

Open kristiandreher opened 3 months ago

kristiandreher commented 3 months ago

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

KeynesYouDigIt commented 3 months ago

Is this potentially related? looks like a dependency conflict

$ npm i @typescript-eslint/eslint-plugin@5.0.0 --save-dev
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: stargate-api@1.0.0
npm error Found: @typescript-eslint/parser@6.21.0
npm error node_modules/@typescript-eslint/parser
npm error   @typescript-eslint/parser@"^6.6.0" from @aws-appsync/eslint-plugin@1.6.0
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/parser@5.62.0
npm error node_modules/@typescript-eslint/parser
npm error   peer @typescript-eslint/parser@"^5.0.0" from @typescript-eslint/eslint-plugin@5.0.0
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.
KeynesYouDigIt commented 3 months ago

bump.

Can someone help me understand? does AWS actively demand people code in the gui???

jimmyn commented 2 months ago

I'm facing the same issue

osadi commented 1 month ago

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.

kristiandreher commented 1 month ago

@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?

osadi commented 1 month ago

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.