aws-appsync-community icon indicating copy to clipboard operation
aws-appsync-community copied to clipboard

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

Open kristiandreher opened this issue 1 year ago • 6 comments

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

kristiandreher avatar Aug 16 '24 12:08 kristiandreher

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.

KeynesYouDigIt avatar Aug 19 '24 15:08 KeynesYouDigIt

bump.

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

KeynesYouDigIt avatar Aug 23 '24 00:08 KeynesYouDigIt

I'm facing the same issue

jimmyn avatar Sep 12 '24 12:09 jimmyn

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 avatar Oct 02 '24 12:10 osadi

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

kristiandreher avatar Oct 11 '24 09:10 kristiandreher

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.

osadi avatar Oct 11 '24 18:10 osadi

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.

EHadoux avatar Nov 25 '24 12:11 EHadoux

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.

timheilman avatar Dec 07 '24 02:12 timheilman

+1

alanoberto avatar Jan 22 '25 12:01 alanoberto

+1

thomasoehri avatar Jan 22 '25 15:01 thomasoehri

+1

naedx avatar Jan 23 '25 21:01 naedx

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

kristiandreher avatar Jan 24 '25 10:01 kristiandreher

Confirmed. I was able to do the same with V2.

Thanks!

naedx avatar Feb 05 '25 12:02 naedx