# JavaScript beta

# Configuration - .deepsource.toml

This section covers configuration specific to javascript analyzer. Please make sure to read the general configuration guide first.

# name

  • Type: String
  • Presence: mandatory
  • Description: Shortcode of the analyzer.
  • Example:
name = "javascript"

# enabled

  • Type: Boolean
  • Presence: mandatory
  • Description: Toggle whether this analyzer should be run.
  • Example:
enabled = true

# meta

  • Type: Table
  • Presence: optional
  • Description: Any supported metadata to pass to the analyzer.
  • Example:
[analyzers.meta]
  environment = ["nodejs","browser","jest"]
  ecma_version = 2020
  module_system = "commonjs"
  plugins = ["react"]
  style_guide = "airbnb"
  dialect = "typescript"

# environment

  • Type: Array

  • Presence: required

  • Description: The global variables related to the environments used that need to be pre-defined for the project.

  • Available Values: nodejs, browser, jest, mocha, jasmine, jquery, mongo

    • nodejs - Adds Node.js global variables and Node.js scoping
    • browser - Adds all the Browser global variables
    • jest - Adds Jest global variables
    • mocha - Adds all the Mocha testing global variables
    • jasmine - Adds all of the Jasmine testing global variables for version 1.3 and 2.0
    • jquery - Adds jQuery global variables
    • mongo - Adds MongoDB global variables
  • Example:

environment = ["nodejs","browser","jest"]

# ecma_version

  • Type: String
  • Presence: optional
  • Description: The ECMAScript(ES) Version the project follows.
  • Available Values: 3, 5, 6, 2016, 2017, 2018, 2019, 2020
  • Default Value:2020
  • Example:
ecma_version = "2018"

# module_system

  • Type: String

  • Presence: optional

  • Description: The type of modules used in the project.

  • Available Values: commonjs, es-modules and amd

    • commonjs - The CommonJS Module System. (require / exports)
    • es-modules - ES Modules (import / export)
    • amd - Asynchronous Module Definition (define / require)
  • Default Value: "commonjs"

  • Example:

module_system = "es-modules"

# plugins

  • Type: Array
  • Presence: optional
  • Description: The JavaScript Frameworks being used in the project. Currently, we support React.
  • Available Value: react
  • Default Value: None
  • Example:
plugins = ["react"]

# style_guide

style_guide = "airbnb"

# dialect

  • Type: String
  • Presence: optional
  • Description: The dialect of JavaScript used in the project. Currently, we support TypeScript
  • Available Value: typescript
  • Default Value: None
  • Example:
dialect = "typescript"

# Sample config

version = 1

test_patterns = ["*/test/**"]

exclude_patterns = [
    "public/**,",
    "dist/**"
]

[[analyzers]]
name = "javascript"
enabled = true

  [analyzers.meta]
  ecma_version = "2016"
  module_system = "commonjs"
  environment = [
    "nodejs",
    "browser",
    "jest",
  ]

  plugins = ["react"]
  style_guide = "airbnb"
  dialect = "typescript"

# ESLint Rules & Plugins

DeepSource JavaScript analyzer fully supports all the ESLint core JavaScript rules. Alongwith that, it currently supports the following ESLint plugins :

We are working to add support for more plugins in order to improve the analysis further.

# Dependency installation

DeepSource installs dependencies in your project in order to get a full picture of your code, and to reduce false positives.

Currently, we support installation of dependencies listed in the package.json present in repository's root folder. The dependencies are installed using the package manager being originally used in your project.

The package managers currently supported are npm and yarn. npm is used as the default if the analyzer is not able to identify the package manager being used in the project.

Last Updated: 8/10/2020, 3:25:16 PM