wttj-config-front

Front-end code lint and formatting config


Keywords
eslint, eslintconfig, prettier, prettierconfig, babel, babelconfig, typescript, tsconfig
License
ISC
Install
npm install wttj-config-front@2.4.0

Documentation

wttj-config

Install

yarn add --dev wttj-config

Eslint

// .eslintrc.js
module.exports = {
  extends: './node_modules/wttj-config/lib/eslint',
  // or if you want typescript configuration
  // extends: './node_modules/wttj-config/lib/eslint/eslintrc-typescript',
  // or if you want cypress configuration
  // extends: './node_modules/wttj-config/lib/eslint/eslintrc-cypress',
}

Prettier

// prettier.config.js
module.exports = require('wttj-config/lib/prettier')

Stylelint

// stylelint.config.js
module.exports = {
  extends: './node_modules/wttj-config/lib/stylelint',
}

Tsconfig

// tsconfig.json
{
  "extends": "wttj-config/lib/tsconfig/tsconfig.json",
  "compilerOptions": {
    "baseUrl": "src"
  },
  "include": ["src"]
}

Translations

We've added a script to run as a lint task that ensures that the keys in translation files are sorted alphabetically.

Scripts

// package.json
{
  "scripts": {
    // ...
    "lint": "yarn lint:js && yarn lint:css && yarn lint:ts && yarn lint:translations",
    "lint:js": "eslint src --max-warnings 0",
    "lint:css": "stylelint 'src/**/styles.ts' --allow-empty-input",
    "lint:ts": "tsc --noEmit",
    "lint:translations": "node -r esm scripts/sort-translations.js",
  }
},

VSCode

Install eslint and prettier extensions

// your settings.json
{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

How to release

yarn release

Then release-it create a new github tag who activate circle ci release action.