codeclimate / codeclimate-eslint

Code Climate Engine for ESLint
MIT License
95 stars 93 forks source link

Add support to monorepos #513

Closed fede-moya closed 3 years ago

fede-moya commented 3 years ago

Some customers have being requesting support for monorepos that have more than one eslint configuration, repos that use 2 .eslintrc.js files or more. ESLint provides this feature out of the box by making use of eslint Cascading and Hierarchy feature.

A customer shared some very interesting findings:

If we only have /a/.eslintrc and /b/.eslintrc (such that directory /a/ has different linting rules than directory /b/) then Code Climate throws this error when attempting to analyze our project:

Error: No ESLint configuration found in /code.at CascadingConfigArrayFactory._finalizeConfigArray 

And he also pointed that if we add a .eslintrc file containing only {} then the analysis goes correctly. Doing some research I found that eslint requires a config file at root level, if not given the previously mentioned error is raise. So, seems like a correct approach to use the baseConfig configuration of eslint's api and set it to {} in order to allow monorepo's analysis and do not alter existen configurations.

Also added some end to end tests that cover this use case.

Resolves https://github.com/codeclimate/codeclimate-eslint/issues/412

fede-moya commented 3 years ago

I really like this idea! Super simple and effective! Do you think it would be worth adding a warning message of some sort if for the cases we end up just using the default rules because no .eslintrc file was found anywhere?

@noelia-lencina I don't think so. For two reasons;

WDYT ?