ITADN

How to adjust configuration like included files or project service?

#88OpenViRuSTriNiTy 创建于 2024-08-26
V
ViRuSTriNiTycommented
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`](https://github.com/xojs/eslint-config-xo-typescript/blob/1f59ada8bf66c11cdda1fe4609288fd2f5c25aff/index.js#L742), therefore I have to adjust the configuration somehow and the only solution I found was mangling the configuration object like ``` es6 // 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 ]; ``` 2) 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: ``` es6 // 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?
1 条评论