@criptext/criptext-js-tools
JS tools used by Criptext
Last updated 6 months ago by criptext .
MIT · Original npm · Tarball · package.json
$ cnpm install @criptext/criptext-js-tools 
SYNC missed versions from official npm registry.

Criptext JS Tools

Lint and format JS code with zero configuration.

Install

yarn add --dev criptext-js-tools

Then add these lines to your package.json:

  "scripts": {
+    "lint": "criptext-js-tools lint",
+    "test": "criptext-js-tools test"
  },

Scripts

Lint

This will format your js files with prettier, and then check them with eslint. Only files inside src will be processed. On a CI environment, no files are modified, instead, when unformatted files are found, an error detailing the filepaths is thrown.

The rules used depend on your project. If your project lists 'react-dom' as a dependency, it is considered a 'frontend' project and eslint-plugin-react's recommended rules are added.

Format

This script takes a file name as parameter and source code via STDIN, and it will format the source code with Prettier and print it to STDOUT. For example you can call it like this:

cat foo.js > criptext-js-tools foo.js

This is useful fo editor plugins that run external commands to format the current buffer. Please note that it is not necessary to pass the actual file name as parameter, as long as the extension is correct, Prettier will be able to figure out which parser it should use.

Test

This will look for unit test files and runs them in parallel with Jest. The pattern used to match test files is Jest's default:

By default it looks for .js and .jsx files inside of tests folders, as well as any files with a suffix of .test or .spec (e.g. Component.test.js or Component.spec.js). It will also find files called test.js or spec.js.

Any command line arguments that you pass to this script will be directly forwarded to Jest.

Integration

This also runs tests with Jest, but it uses a different pattern for matching tests and runs them sequentially (using --runInBand). This script matches any file that ends in .integration.js. Without parallelization the test suite is slower but it is useful for testing how well your program integrates with stateful external elements like databases.

Current Tags

  • 0.5.2                                ...           latest (6 months ago)

2 Versions

  • 0.5.2                                ...           6 months ago
  • 0.5.1                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (9)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |