Configure ESLint in apigeelint

Is it possible to use a custom ESLint configuration with apigeelint?

If so, how?

Solved Solved
1 10 484
1 ACCEPTED SOLUTION

No, based on my understanding of the eslint documentation, and my reading of the current source of apigeelint, the plugin for eslint does not support external configuration! I am surprised. That's an unfortunate limitation.

I am not completely certain of this, because the documentation of the eslint npm module is not quite as clear as I would like. The current code of apigeelint passes a hardcoded set of rules to the linter. What I am uncertain about is, does the eslint.Linter object implicitly scan for an .eslintrc file and apply its rules? I suppose it would be easy to test.

If the eslint.Linter object does not implicitly read .eslintrc files, I think it would not be too difficult to extend apigeelint to read an .eslintrc file that you specify, somehow. Maybe apigeelint should automatically look for .eslintrc in the root of the bundle. Would that work for your purposes? Let me ask something different: how would you like to specify the eslint rules? If we find that its necessary, I can work on a Pull request that would extend it to support externally-specified rules.

One [lame] workaround: you can specify in-line rules, within the JS code. This is ok for small codebases, but obviously is tedious and wrong for the case where you have lots of files to analyze.

View solution in original post

10 REPLIES 10

No, based on my understanding of the eslint documentation, and my reading of the current source of apigeelint, the plugin for eslint does not support external configuration! I am surprised. That's an unfortunate limitation.

I am not completely certain of this, because the documentation of the eslint npm module is not quite as clear as I would like. The current code of apigeelint passes a hardcoded set of rules to the linter. What I am uncertain about is, does the eslint.Linter object implicitly scan for an .eslintrc file and apply its rules? I suppose it would be easy to test.

If the eslint.Linter object does not implicitly read .eslintrc files, I think it would not be too difficult to extend apigeelint to read an .eslintrc file that you specify, somehow. Maybe apigeelint should automatically look for .eslintrc in the root of the bundle. Would that work for your purposes? Let me ask something different: how would you like to specify the eslint rules? If we find that its necessary, I can work on a Pull request that would extend it to support externally-specified rules.

One [lame] workaround: you can specify in-line rules, within the JS code. This is ok for small codebases, but obviously is tedious and wrong for the case where you have lots of files to analyze.

Craig, I've filed a pull request on the apigeelint project, modifying the eslint plugin to read eslintrc files in the directory hierarchy.

https://github.com/apigee/apigeelint/pull/178

That's awesome. Thanks Dino

Hi Craig,

I believe Sai has merged this pull request into master, which means if you get the latest apigeelint , you will have this capability.

Yep - we upgraded and it's now reading our ESLint config. Thanks for the swift turnaround.

The ESLint issues are all getting flagged as 'warning' instead of 'error'. Is there a way to configure how Apigeelint handles ESLint issues?

Hmm

I hadn't noticed that, but now I see the same results that you're describing. It's because the apigeelint tool is overriding any severity that is set in the eslint messages. The fix is simple. I've created another pull request for this.

https://github.com/apigee/apigeelint/pull/184

@Sai Saran Vaidyanathan FYI

@Dino-at-Google - its pushed to npm. Please get the latest version

Whoo-hoo, thanks Sai. Craig, back to you.

It works like a charm! Many thanks.