eslint_d.js icon indicating copy to clipboard operation
eslint_d.js copied to clipboard

Working setup for Sublime Text + eslint_d + ESLint-Formatter

Open caenrigen opened this issue 2 years ago • 2 comments

Hi there! Thank you very much for this great package!

I managed to make it work with my Sublime Text through a Sublime Text package (ESLint-Formatter). Leaving this information here in case someone else finds it useful, feel free to add it to the readme, or link to this comment.

Working setup for Sublime Text + eslint_d + ESLint-Formatter

Requirements:

  • Sublime Text Package Manager
  • ESLint-Formatter (v2.4.2 as of the writing time)
  • node/yarn project
  • eslint + any packages that you use, I installed it only locally in my project
  • eslint_d, also installed locally in my project

The caveats:

ESLint-Formatter seems to have some bugs and has not been updated for a while now, but I managed to get a working setup with a few tricks. Here is how my typescript project configuration looks like my-typescript-proj.sublime-project:

{
    "folders": [
        {
            "path": ".",
            "folder_exclude_patterns": [
                "node_modules",
                "lib"
            ]
        }
    ],
    "settings": {
        "ESLint-Formatter": {
            "format_on_save": true,
            "format_on_save_extensions": [
                "js",
                "ts",
                "jsx",
                "tsx",
            ],
            "config_path": ".eslintrc.js",
            "debug": false, // print to SublimeText's Console (Show Console menu) for debugging
            // This should be working but the plugin is broken and this empty string at
            // least forces the plugin to use the `eslint_path` below
            "local_eslint_path": {
                "windows": "",
                "linux": "",
                "osx": ""
            },
            // Because the above is broken the only way is to use the full path here
            "eslint_path": {
                "windows": false,  // edit if this is your platform
                "linux": false,  // edit if this is your platform
                // Normal command
                // "osx": "/full/path/to/your/project/node_modules/.bin/eslint"
                // Server-based command, for speed, `npm install eslint_d --save-dev`
                "osx": "/full/path/to/your/project/node_modules/.bin/eslint_d"
            },
            // Required for typescript projects that include a config file
            "extra_args": [
                "--parser-options={\"tsconfigRootDir\": \"$project_path/\"}"
            ]
        }
    }
}

Version details for reference: macOS: 11.4 Sublime Text 4: 4126 Other Sublime Text packages in use:

  • https://github.com/sublimelsp/LSP
  • https://github.com/sublimelsp/LSP-typescript
  • http://www.sublimelinter.com/en/stable/
  • https://github.com/SublimeLinter/SublimeLinter-eslint

Some of my dev dependencies in package.json:

"devDependencies": {
  "@typescript-eslint/eslint-plugin": "^5.17.0",
  "@typescript-eslint/parser": "^5.17.0",
  "eslint": "^8.12.0",
  "eslint-config-prettier": "^8.5.0",
  "eslint-plugin-import": "^2.25.4",
  "eslint-plugin-prettier": "^4.0.0",
  "eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
  "eslint-plugin-unused-imports": "^2.0.0",
  "eslint_d": "^12.2.0",
  "husky": "^7.0.2",
  "lint-staged": "^12.3.7",
  "prettier": "^2.7.1",
  "ts-node": "^10.7.0",
  "typescript": "^4.6.3"
}

caenrigen avatar Jun 20 '22 17:06 caenrigen

You probably want "fix_to_stdout": true in there too?

IPWright83 avatar Sep 26 '22 18:09 IPWright83

You probably want "fix_to_stdout": true in there too?

it has been a while since I configured this, not sure where this option would be specified.

let me know if you make it work somehow and it performs better

caenrigen avatar Sep 28 '22 09:09 caenrigen