Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

better-coding-script

prma8517MIT3.0.0

A set of scripts to run in JavaScript and Typescript projects to easily parse your code through ESLint recommended rules and prettier. It also has specific rules for React projects (both JSX and TSX).

eslint, prettier, tslint, lint, react, javascript, typescript

readme

Better Coding Script

npm version Codacy Badge

This package is a set of scripts to run in JavaScript and Typescript projects to parse your code easily through ESLint recommended rules and prettier. It also has specific rules for React projects (both JSX and TSX).

This is the initial idea, and I have already been using it for a long list of projects, so, decided to share it with the community.

Installation

npm install better-coding-script --save-dev

or

yarn add better-coding-script --dev

You can also install the package globally (-g) to run it in any project without adding a new dependency!

Style Guide

It uses an automatic code formatter called Prettier. Run bcs prettier after making any changes to the code.

Then, our linter will catch most issues that may exist in your code. You can check the status of your code styling by simply running bcs linc.

However, there are still some styles that the linter cannot pick up. If you are unsure about something, looking at Airbnb’s Style Guide will guide you in the right direction.

Usage

The main command is better-coding-script but there is a short/alias as bcs

npx better-coding-script <command> <option>

Or add a script to your packages.json

"command": "bcs <command> <option>"

API

lint       run ESLint for all files in the project (add --fix to apply the fixes)
linc       run ESLint for modified files only in the project (add --fix to apply the fixes)
prettier   run Prettier check for all files in the project
           Additional Options:
              check-changed    run Prettier check for modified files only in the project
              write            run Prettier and fix styling for all files in the project
              write-changed    run Prettier and fix styling for modified files only in the project

Using each command

  • bcs lint: run ESLint for all files in the project
  • bcs lint --fix: run ESLint for all files and fix the code when possible in the project
  • bcs linc: run ESLint for modified files only in the project
  • bcs linc --fix: run ESLint for modified files only and fix the code when possible in the project
  • bcs prettier: run Prettier check for all files in the project
  • bcs prettier check-changed: run Prettier check for modified files only in the project
  • bcs prettier write: run Prettier and fix styling for all files in the project
  • bcs prettier write-changed: run Prettier and fix styling for modified files only in the project
  • bcs -h: show list of commands
  • bcs -v: show version

ESLINT in your project

Create a file called .eslintrc.js and add the following content

module.exports = {
  extends: [require.resolve('better-coding-script')],
};

Other points

Code of Conduct

I decided to adopted (as Facebook) the [Contributor Covenant]https://www.contributor-covenant.org/) as our Code of Conduct, and we expect project participants to adhere to it. Please read the full text so that you can understand what actions will and will not be tolerated.

Semantic Versioning

Better Coding Script follows semantic versioning. We release patch versions for critical bugfixes, minor versions for new features or non-essential changes, and major versions for any breaking changes.

Branch Organization

Submit all changes directly to the master branch. We don’t use separate branches for development or for upcoming releases. We do our best to keep master in good shape, with all tests passing.

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[3.0.0] - 02/15/2023

Updated

  • Dependencies

Added

  • eslint-plugin-sonarjs
  • eslint-plugin-unicorn

[2.1.0] - 07/11/2021

Updated

  • Dependencies

Added

  • Airbnb prettier plugin

[2.0.0] - 06/16/2021

Updated

  • Dependencies
    • All ESlint plugins
    • Prettier

Added

  • Direct extension of Airbnb style guide
  • Additional rules for react and typescript from eslint-config-react-app

[1.0.2] - 10/12/2020

Fixed

  • Remove "\r" and "\n" from the branch name

[1.0.1] - 10/09/2020

Fixed

  • Auto detect default branch instead of always using master

[1.0.0] - 09/21/2020

Added

  • Initial implemenation