Skip to content

flowerpress/eslint-plugin-fpcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eslint-plugin-fpcs

npm version npm (prod) eslint dependency version npm (prod) mocha dependency version npm bundle size npm downloads NPM License

FPCS eslint style rules.

Installation

  1. yarn add --dev eslint-plugin-fpcs
  2. Install peer dependencies. Most of the peer dependencies on this package are optional, only required for certain platforms.

Migrating from v1.x to v2.x

  1. Update your project's package.json devDependencies to use "eslint-plugin-fpcs": "^2.0.0"
  2. Run yarn
  3. Follow "Install peer dependencies" instruction from "Installation" section above.

💔 Breaking changes from v1.x

Babel has been split off into a separate config

If you use babel, you will need to add "plugin:fpcs/babel" to the extends section of your .eslintrc file. Make sure to place it directly after base, before any other configs like typescript or react.

prefer-default-export removed in favor of opposite no-default-export

FPCS has decided to move to always using named exports. See discussion in style guide.

To use v2 you will need to do one of the following:

  • Change all default exports to named exports in your codebase.
  • Add eslint-disable import/no-default-export for every default export in your codebase.
  • Add the following to your codebase's .eslintrc file:
rules: {
  'import/no-default-export': 'off',
  'import/prefer-default-export': 'warn',
  'no-restricted-exports': 'off',
}

Alternatively, you may stay on v1.x, but future updates may not be applied to the v1.x tree.

Usage

Add desired config sets to the extends section of your .eslintrc or .eslintrc.js configuration file.

Available configs:

  • plugin:fpcs/base
  • plugin:fpcs/babel
  • plugin:fpcs/react
  • plugin:fpcs/react-typescript
  • plugin:fpcs/typescript
  • plugin:fpcs/vue

JavaScript / ECMAScript

{
    "extends": [ "plugin:fpcs/base" ],
}

TypeScript

{
    "extends": [
        "plugin:fpcs/base",
        "plugin:fpcs/typescript",
    ],
}

React

{
    "extends": [
        "plugin:fpcs/base",
        "plugin:fpcs/react",
    ],
}

React TypeScript (automatically adds fpcs/react and fpcs/typescript)

{
    "extends": [
        "plugin:fpcs/base",
        "plugin:fpcs/react-typescript",
    ],
}

Vue

{
    "extends": [
        "plugin:fpcs/base",
        "plugin:fpcs/vue",
    ],
}

Babel

Typically used on a React app that gets transpiled by babel.

{
    "extends": [
        "plugin:fpcs/base",
        "plugin:fpcs/babel",
        ...if you extend other configs place them here, AFTER babel...
    ],
}

Add or modify individual rules:

Add desired config sets to the rules section of your .eslintrc or .eslintrc.js configuration file.

  "rules": {
    "@typescript-eslint/consistent-type-assertions": "off",
  },

Available Custom Rules

  • fpcs/no-gremlin-chars (automatically set to 'error' when using base config)
  • fpcs/prefer-early-return (automatically set to 'error' when using base config)

Development

To develop on this package, I strongly recommended that you use yalc. Yalc solves issues related to peer dependencies not symlinking correctly when using yarn link on local. Just run yalc publish in this repo and then yalc add eslint-plugin-fpcs && yarn in the user repo after every change.