You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio是否支持ESLint?求替代方案及自动保存格式化方法

Android Studio & ESLint: Support, Alternatives, and Auto-Formatting

Great question! Since Android Studio shares the same IntelliJ IDEA foundation as PHPStorm and WebStorm, it absolutely can work with ESLint—though it might need a quick setup if you’re not already working on web-related projects. Let’s break this down:

Does Android Studio support ESLint?

Yes, it does! Here’s how to get it up and running smoothly:

  • First, ensure the JavaScript and TypeScript plugin is enabled (it’s usually pre-installed, but double-check in Settings > Plugins to be safe).
  • Make sure your project has ESLint installed locally (run npm install eslint --save-dev or the yarn equivalent) and an .eslintrc configuration file set up.
  • Head to Settings > Languages & Frameworks > JavaScript > Code Quality Tools > ESLint and toggle on "Automatic ESLint configuration" (this will detect your local ESLint setup automatically). If that doesn’t pick it up, you can manually point to your ESLint package path.

Once configured, Android Studio will highlight ESLint issues in your code and let you run fixes just like in WebStorm.

Alternatives to ESLint in Android Studio

If for some reason you don’t want to use ESLint, there are a few built-in or easily integratable options:

  • JSHint: A lightweight, straightforward linter for JavaScript. Android Studio has native support for it—just enable it in the same code quality tools settings menu and set up a .jshintrc file.
  • Prettier: While not a linter (it’s a dedicated code formatter), it’s a popular companion to linters. Android Studio integrates seamlessly with Prettier, and you can set it up to format your code on save (more on that below).
  • TSLint: Note that TSLint is deprecated now, but if you’re maintaining an older TypeScript project that uses it, Android Studio still supports it. That said, migrating to ESLint is the recommended long-term path.

Auto-formatting on save with Android Studio’s built-in tools

Absolutely! You don’t need external tools to get auto-formatting working. Here’s how to set it up:

  1. Open Settings > Tools > Actions on Save (for older Android Studio versions, look under Settings > Editor > General > Editor Tabs > Save Actions).
  2. Check the box for Reformat code. You can click the gear icon next to it to choose which file types (like JavaScript, TypeScript, Java, etc.) you want this to apply to.
  3. If you’re using ESLint, you can also check Run eslint --fix in the same menu to auto-resolve fixable ESLint issues every time you save.

This will keep your code consistently formatted without any extra manual steps.

Content of the question originates from stack exchange, question author Aksenov Vladimir

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:49:03