首页 > 解决方案 > Sublime Text 4 - 如何设置 LSP-eslint

问题描述

当使用 Sublime text 3 时,我有SublimeLinterSublimeLinter-eslint包,以及用于 JS 和 JSX 语法的eslintbabel-eslint全局节点模块。

随着切换到 Sublime 4,我决定尝试LSP。我安装了它,还安装了LSP-css(开箱即用)和LSP-eslint,但无法正常工作。

如果我检查 Sublime 的状态栏,我会看到语言服务器显然正在运行(?) 在此处输入图像描述

这是在一个项目中,它有自己的eslintrc.js配置文件,它在 VScode 中开箱即用。部分如下:

const RulesAirBnb = require("eslint-config-airbnb-base/rules/best-practices");
const RulesCRA = require("eslint-config-react-app");

module.exports = {
    root: true,

    parser: "babel-eslint",
    parserOptions: {
        ecmaVersion: 2018,
        sourceType: "module",
        ecmaFeatures: {
            jsx: true,
            generators: true,
        },
    },

    extends: [
        "airbnb", // Baseguide is AirBnB"s
        "prettier",
        "prettier/react",
    ],

检查了以下SO 问题,但没有运气。

标签: eslinteslintrceslint-config-airbnblanguage-server-protocolsublimetext4

解决方案


安装LSP- typescript 就可以了,开箱即用,甚至不需要 lsp-eslint。虚幻。

经过几天的研究,在这里找到了信息(感谢 chrsap!)。

如果您正在运行 ST3,请查看LSP-typescript 的自述文件以获取所需的包。


推荐阅读