# 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
- Type: String (opens new window)
- Presence: mandatory
- Description: Shortcode of the analyzer.
- Example:
name = "javascript"
# enabled
- Type: Boolean (opens new window)
- Presence: mandatory
- Description: Toggle whether this analyzer should be run.
- Example:
enabled = true
# meta
- Type: Table (opens new window)
- 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"
# 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 scopingbrowser
- Adds all the Browser global variablesjest
- Adds Jest global variablesmocha
- Adds all the Mocha testing global variablesjasmine
- Adds all the Jasmine testing global variables for version 1.3 and 2.0jquery
- Adds jQuery global variablesmongo
- 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
Presence: optional
Description: The type of modules used in the project.
Available Values:
commonjs
,es-modules
andamd
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 (opens new window)
- Presence: optional
- Description: The JavaScript Frameworks being used in the project. Currently, we support React (opens new window),Vue (opens new window), EmberJS (opens new window), Meteor (opens new window), Angular (opens new window) and AngularJS (opens new window).
- Available Values:
react
,vue
,ember
,meteor
,angular
andangularjs
- Default Value: None
- Example:
plugins = ["react"]
# style_guide
Presence: optional
Description: The preferred style guide to be used in the project.
Available Values:
airbnb
,google
andstandard
Default Value: None
Example:
style_guide = "airbnb"
# dialect
- Type: String (opens new window)
- Presence: optional
- Description: The dialect of JavaScript used in the project. Currently, we support TypeScript (opens new window) and Flow (opens new window).
- Available Value:
typescript
andflow
- 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
The DeepSource JavaScript analyzer fully supports all the ESLint core JavaScript rules. Along with that, it currently supports the following ESLint plugins :
- Node
- TypeScript
- React
- Vue
- Flow
- Ember
- Meteor
- Angular
- AngularJS
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.