Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ViRuSTriNiTy opened this issue Aug 26, 2024 · 0 comments
Open

Comments

@ViRuSTriNiTy
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant