Skip to content

Commit

Permalink
Merge pull request #192 from apollographql/upgrade-eslint
Browse files Browse the repository at this point in the history
Upgrade to latest eslint
  • Loading branch information
jerelmiller authored Feb 3, 2025
2 parents eb39a07 + 0954a3f commit ebd0ebe
Show file tree
Hide file tree
Showing 10 changed files with 3,028 additions and 2,375 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

70 changes: 0 additions & 70 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions client/src/components/AlbumTrackTitleCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const PLAYBACK_STATE_FRAGMENT = gql`

fragmentRegistry.register(gql`
fragment AlbumTrackTitleCell_album on Album {
id
uri
}
Expand Down
9 changes: 4 additions & 5 deletions client/src/mutations/useAddToPlaylistMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,13 @@ const useAddToPlaylistMutation = () => {
return execute({
variables: { input },
update: (cache) => {
cache.modify({
cache.modify<Playlist>({
id: cache.identify({
__typename: 'Playlist',
id: input.playlistId,
}),
fields: {
tracks: (
tracks: Playlist['tracks'],
{ readField, toReference }
) => {
tracks: (tracks, { readField, toReference }) => {
const edges =
readField<PlaylistTrackEdgeWithNodeRef[]>('edges', tracks) ??
[];
Expand All @@ -83,6 +80,8 @@ const useAddToPlaylistMutation = () => {
return {
...tracks,
edges: edges.concat(refs),
// TODO: See if we can fix this type
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any;
},
},
Expand Down
130 changes: 130 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import graphql from '@graphql-eslint/eslint-plugin';
import globals from 'globals';
import js from '@eslint/js';
import ts from 'typescript-eslint';

export default ts.config(
{
ignores: ['**/dist', '**/__generated__'],
},
js.configs.recommended,
ts.configs.recommended,
{
files: ['**/*.config.js'],
languageOptions: {
globals: {
...globals.node,
},
},
},
{
files: ['client/src/**/*.{ts,tsx}'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: 'client/tsconfig.json',
},
},
},
{
files: ['subgraphs/spotify/**/*.{ts,tsx}'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: 'subgraphs/spotify/tsconfig.json',
},
},
},
{
files: ['subgraphs/playback/**/*.{ts,tsx}'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: 'subgraphs/playback/tsconfig.json',
},
},
},
{
rules: {
'@typescript-eslint/no-unused-expressions': [
'error',
{ allowTernary: true },
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
},
],
},
},
{
files: [
'subgraphs/spotify/src/**/*.ts',
'subgraphs/playback/src/**/*.ts',
'scripts/**/*.ts',
],
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
},
},
{
files: ['client/src/**/*.{ts,tsx}'],
extends: [
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
],
plugins: {
react,
'react-hooks': reactHooks,
},
languageOptions: {
globals: {
...globals.browser,
},
},
settings: {
react: {
version: 'detect',
},
linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }],
},
rules: {
...reactHooks.configs.recommended.rules,
'react/display-name': 'off',
},
},
{
files: ['client/src/**/*.{ts,tsx}'],
processor: graphql.processor,
},
{
files: ['client/src/**/*.graphql'],
ignores: ['client/src/apollo/localSchema.graphql'],
extends: [graphql.configs['flat/operations-recommended']],
languageOptions: {
parser: graphql.parser,
},
plugins: {
'@graphql-eslint': graphql,
},
rules: {
'@graphql-eslint/known-directives': [
'error',
{ ignoreClientDirectives: ['client', 'connection', 'synthetics'] },
],
'@graphql-eslint/naming-convention': [
'error',
{
FragmentDefinition: {
ignorePattern: '.+_.+',
},
},
],
'@graphql-eslint/no-deprecated': 'warn',
'@graphql-eslint/no-unused-fragments': 'off',
},
}
);
Loading

0 comments on commit ebd0ebe

Please sign in to comment.