# JavaScript beta

# Configuration - .deepsource.toml

This section covers configuration specific to the 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 the package.json file, if it is found in the repository's root.

# environment

  • Type: Array (opens new window)

  • Presence: required

  • Description: The global variables related to the environments used that need to be predefined 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 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

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

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

# Dependencies Calculation

DeepSource uses package-lock.json and yarn.lock to calculate direct and indirect dependencies. We don't update any of the lockfiles.

If you have the lockfile and you receive 0 direct and indirect dependencies, it may be because of the following reasons :

  • You have not installed the peerDependencies correctly.
  • You are using a private node package.
Last Updated: 1/14/2021, 12:08:34 PM