Skip to content

geostarters/js-project-template

Repository files navigation

Javascript Project Template

Base javascript project with a default configuration

  • Uses unassert to encourage programming with assertions
  • Generates a single file package using browserify
  • Uses st to provide a server to serve static files for quick debugging of the package
  • Uses documentation.js to generate a JSON file to be consumed by another package (see the documenting the code section) (TODO: Ingest it with @mapbox/batfish?)
  • Uses eslint to perform static analysis in code
  • Uses flow to check types (see the using types section)
  • Uses node-tap for testing (see the writting tests section)
  • Uses nyc to run Istanbul's coverage testing
  • Provides a small source file and its corresponding test as an example

Documenting the code

The documentation follows the JSDoc syntax.

To get started you can read the documentation.js start guide here or take a look at the provided example file here

Using types

Using flow provides a way to check for common syntax errors while calling functions. Flow provides a simple example of which kind of problems it can solve in their Type Annotations guide. There's also a list of annotations it supports there.

Writting tests

Node-tap implements the Test Anything Protocol.

Take a look at the Node-tap API to check all the supported functions.

Check the provided example file to see how node-tap testing looks.

Run the testing coverage script to see which percentage of code is being tested. Aim for the moon, bigger is obviously better.

Provided scripts

  • build-dev: Creates a single file package with all the assertions intact.
  • watch-dev: Watches the source
  • build-min: Creates a minified package with its map file and without assertions
  • start-server: Starts a debug server on the current directory
  • start: Watches the source for changes and runs the debug server
  • build-docs: Generates the documentation file
  • lint: Checks the code linting
  • lint-docs: Lints the documentation files
  • test: Runs the static type checker and runs the tests
  • test-unit: Runs the unit tests
  • test-flow: Runs the static type checks
  • test-cov: Runs the testing coverage
  • pre-production: Runs all the required scripts to check if the code is ready for production

Folder structure

debug: Contains a simple html file that loads the generated package file. All the functionalities should have an html file here demoing how it works

dist: Contains the built files generated by the scripts (dev package, minified package and map)

src: Contains an index file that requires all the modules that should be exported and all the source files that compound the package.

test: Contains the unit and integration tests

About

A Javascript project template

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published