Skip to content

How to adjust configuration like included files or project service? #88

Open
@ViRuSTriNiTy

Description

Hi there,

I have updated my project to ESLint 9 and all packages required for this to the latest version. Among all these packages I eslint-config-xo-typescript to enable linting for TypeScript files. Two issues arise from this:

  1. In my case the file extension is .ts but eslint-config-xo-typescript uses .tsx, therefore I have to adjust the configuration somehow and the only solution I found was mangling the configuration object like
// eslint.config.mjs
import xoTypeScript from 'eslint-config-xo-typescript';

const tsxConfigurationObject = xoTypeScript[xoTypeScript.length - 1];

// Include .ts files in liniting, required because file extension .tsx is configured by default
tsxConfigurationObject.files.push('**/*.ts');

export default [
  ...xoTypeScript
];
  1. With the update to ESLint 9 the config file needs to use the .mjs extension to have the config file linted correctly but this causes addtional errors thrown by the project service. To fix this the following configuration is needed:
// eslint.config.mjs
import xoTypeScript from 'eslint-config-xo-typescript';

const tsConfigurationObject = xoTypeScript[1];

// https://github.com/typescript-eslint/typescript-eslint/issues/9739#issuecomment-2296442418
tsConfigurationObject.languageOptions.parserOptions.projectService = {
    allowDefaultProject: ['eslint.config.mjs'],

    ...
};

export default [
  ...xoTypeScript
];

TLDR;

I need to mangle with the configuration object returned from import. The use of index-based access raises a warning flag on my side because this could break easily. So, is there another way to adjust the configuration or is there any plan to support adjustments?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions