Vscode-eslint: .eslintrc.js does not have suggestions

Created on 31 Aug 2016  路  20Comments  路  Source: microsoft/vscode-eslint

_From @isidorn on August 30, 2016 13:34_

Refs #11100

  1. Simple repo, initiazlie eslint, .eslintrc.js gets created
  2. Open .eslintrc.js and triggere intelli-sense -> no suggestions
  3. As found while discussing with @dbaeumer the issue here is that this file is .js and not .json
  4. I would expect suggestions to help me set this file up

_Copied from original issue: Microsoft/vscode#11213_

feature-request

Most helpful comment

Sorry, I didn't see the original question. Today I think your best bet would be to install @types/eslint and use a JSDoc annotation to get completions.

/**
 * @type {import("eslint").Linter.Config}
 */
const config = {
  // ...
}
module.exports = config;

All 20 comments

Might be hard to achieve since we need to tell the tsserver about a d.ts eslint file under the cover. On top of this we would need to maintain such a file.

Any movement on this? Not getting any linting based on this file.

No movement so far.

There is intellisense in .eslintrc or .eslintrc.json, but not in .eslintrc.js.

Up - still needed!

Filename .eslintrc is deprecated and .eslintrc.js does NOT have intelliSense.

/cc @dbaeumer

Edit:
I found out that the json version still allows you to have comments etc, so it really doesn't matter anymore I guess.

Yup, there's code assist support for JSON, but conditionals are problematic.

Here's a default vue setup, _.eslintrc.js_, with ENV conditionals.

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: ["plugin:vue/essential", "@vue/prettier", "@vue/typescript"],
  rules: {
    "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off"
  },
  parserOptions: {
    parser: "@typescript-eslint/parser"
  }
};

Any update on this?
Still looking around for a solution but it seems like this is a/the proper issue to follow.

As I was trying to explain this is something that needs to come from the TS / JS server. Let me ping someone in the TS team if there is any way to inject a d.ts for a specific file.

@DanielRosenwasser is there any way I can teach the TypeScript server to check a certain file using a specific d.ts. file. For example by using some sort of meta comment in the file ?

Any more updates on this?

@DanielRosenwasser any updates on comment https://github.com/microsoft/vscode-eslint/issues/124#issuecomment-580174734

Sorry, I didn't see the original question. Today I think your best bet would be to install @types/eslint and use a JSDoc annotation to get completions.

/**
 * @type {import("eslint").Linter.Config}
 */
const config = {
  // ...
}
module.exports = config;

@DanielRosenwasser THANKS!!

Will close the issue then since there is nothing ESLint needs to do here.

I don't think this suggestion is ideal. You're saying add a JSDoc to every TypeScript file in my repo?

Ahhh, no, just the config JavaScript?

Interesting, lemme give this a try within the hour

@cdbattags correct.

@cdbattags Just to the .eslintrc.js file. Or why do you need ESLint types/autocompletion in every single file?

Might I open/add a different ticket for the long term?

Ideally I don't want to have to remember to add this annotation to each new repo/config.

I don't mind attempting the work on this.

IMO this should be handled by the eslint init command. There is nothing I in the ESLint extension can do about this.

@DanielRosenwasser The JSDoc import snippet doesn't seem to work. Intellisense works for .eslintrc.json and works for JS syntax generally in .eslintrc.js.

Was this page helpful?
0 / 5 - 0 ratings