# JavaScript beta

# Configuration - .deepsource.toml

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

# name

name = "javascript"

# enabled

enabled = true

# meta

[analyzers.meta]
  environment = ["nodejs","browser","jest"]
  ecma_version = 2020
  module_system = "commonjs"
  plugins = ["react"]
  style_guide = "airbnb"
  dialect = "typescript"

# dependency_file_paths

  • Type: Array (opens new window)
  • Presence: optional
  • Description: List of paths of files (package.json) that contain the list of external dependencies, relative to repository's root.
  • Example:
dependency_file_paths = [
  "src/client/package.json",
  "src/server/package.json",
  "app/package.json"
]

TIP

By default the analyzer automatically detects and scans for dependencies / package.json file, if found in repository's root.

# environment

  • Type: Array (opens new window)

  • 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 (opens new window)
  • 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 (opens new window)

  • 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

plugins = ["react"]

# style_guide

style_guide = "airbnb"

# dialect

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 (opens new window) and yarn (opens new window). npm is used as the default if the analyzer is not able to identify the package manager being used in the project.

Last Updated: 10/17/2020, 1:48:35 PM