WARNING!
This package is deprecated.
Features have been migrated to create-iamturns-app and iamturns-scripts.
iamturns-js-toolbox
Toolbox for my JavaScript projects
- Sensible default configs for Jest, Prettier, and lint-staged
- Useful scripts: format, lint, validate, upgrade, reinstall, and reset
- TypeScript supported
Table of Contents
Install
npm install iamturns-js-toolbox --save-dev
Configs
Jest
- Collect coverage from src/
- TypeScript support
- Web mode, enables jsdom and sets testURL
Example jest.config.js
file:
const { createJestConfig } = require("iamturns-js-toolbox")
module.exports = createJestConfig({
srcPath: "app",
web: true,
})
Prettier
- Default settings with exceptions:
- No semi colons
- Why include an unnecessary character at the end of every line? Break the habit (automatically)!
- Trailing commas
- Helps with git merging and conflict resolution
- Ensure .editorconfig is parsed as YAML
Example prettier.config.js
file:
const { createPrettierConfig } = require("iamturns-js-toolbox")
module.exports = createPrettierConfig()
lint-staged
- Format, lint, and test staged files
- README.md changed? Update "Table of Contents" (using doctoc)
Example lint-staged.config.js
file:
const { createLintStagedConfig } = require("iamturns-js-toolbox")
module.exports = createLintStagedConfig({
skipDoctoc: true,
skipFormat: true,
skipLint: true,
skipTest: true,
})
Scripts
iamturns-js-toolbox format
-
Run Prettier on all supported files (js, ts, css, json, md, yaml, etc).
-
Run ESLint with --fix
to automatically fix any linting issues.
Note: all files will be formatted. Use a .prettierignore file to prevent formatting specific files or directories.
Example .prettierignore
file:
/node_modules
/package-lock.json
iamturns-js-toolbox lint
Run ESLint on all supported files.
Note: all files will be linted. Use an .eslintignore file to prevent linting specific files or directories.
Example .eslintignore
file:
/node_modules
iamturns-js-toolbox validate
Concurrently run lint
, test
, and build
commands.
iamturns-js-toolbox pre-commit
Run lint-staged, then run build
command.
Note: lint-staged
requires a configuration file.
iamturns-js-toolbox upgrade
-
Update /node_modules
and /package-lock.json
according to semver rules defined in /package.json
files.
This is a safe operation (assuming dependencies correctly follow semantic versioning).
-
Once complete, check for outdated dependencies (outside of semver rules in /package.json
), and interactively select dependencies to update.
iamturns-js-toolbox reinstall
Remove /node_modules
and reinstall.
iamturns-js-toolbox reset
Reset to a fresh git checkout and reinstall.
Inspiration
Credits
Authored and maintained by Matt Turnbull (iamturns.com / @iamturns)
To all contributors (if you exist) - thank you!
License
Open source software licensed as MIT.