如何根据eslint制作WebStorm格式代码? [英] How to make WebStorm format code according to eslint?

查看:124
本文介绍了如何根据eslint制作WebStorm格式代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为WebStorm项目指定了eslint配置。但这似乎不适用于代码重新格式化功能。例如,它继续将 import {something}从某处 格式化为 import {something}从某处

I've specified eslint configuration for my WebStorm project. But it does not seem to apply to code reformat feature. For example, it continues to format import { something } from 'somewhere' as import {something} from 'somewhere'.

是否有一种方法可以使WebStorm根据eslint配置格式化代码?

Is there a way to make WebStorm to format code according to eslint configuration?

推荐答案

(描述的步骤和屏幕截图来自 IntelliJ IDEA 2017.2

(Described steps and screenshots are from IntelliJ IDEA 2017.2)

您可以为操作 Fix ESLint添加键盘快捷键问题'。 确保插件 JavaScript支持已安装并启用

You can add a keyboard shortcut to action 'Fix ESLint Problem'. Ensure plugin 'JavaScript Support' is installed and enabled.

首先进入首选项 | 语言和框架 | JavaScript | 代码质量工具 | ESLint 并启用它。您将需要定义节点解释器, ESlint软件包和可选的配置文件。

First got to Preferences | Language & Frameworks | JavaScript | Code Quality Tools | ESLint and enable it. You will need to define your 'Node interpreter', 'ESlint package' and optional 'Configuration file'.

下一步转到首选项 | 键盘映射,然后在其中搜索 eslint。现在,您可以添加例如快捷键 control + shift + L。

Next go to Preferences | Keymap and search there for 'eslint'. Now you can add for example the shortcut 'control + shift + L'.

这篇关于如何根据eslint制作WebStorm格式代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆