Skip to content

Is there a way to configure Tern to use plugins and type definitions on some files only? #1059

Description

@downwater

Disclaimer: I also posted this question on StackOverflow.

I set up a web project with a static HTML file and some vanilla JavaScript files. I'm using Jest to perform unit tests on them.

I'm using Tern with Emacs to have some completions.

I want to get a conditional applying of type definitions and plugins on path patterns:

  • node plugin to be active only in unit test files handled by Jest, matching .*.test.js, to get variables like process and __dirname.
  • browser type definitions applied only in JavaScript files not matching .*.test.js to have in web scripts some definitions like the Document interface of the DOM API.

How can I achieve that? Is there a better approach?

Here is my .tern-project so far:

{
  "libs": [
    "ecmascript",
    "browser"
  ],
  "plugins": {
    "es_modules": {},
    "node": {}
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions