Skip to content

PALifeH5/eslint-standard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESLint Standard

Standards for ECMAScript Projects of PALife.

Basically we use AirBnB's ESLint rules, however we make some exceptions.

Basic Rules

Exceptions

See .eslintrc file for exceptional rules.

Explanations for Rules

Walk around examples folder to see explanations for each rules. We try to explain why, how to use a rule and give some correct or wrong example codes.

Usage

  1. If there is no package.json in your project, add it(skip this step if it already exists):

    npm init
    
  2. Save these libraries to your project's devDependencies:

    npm i babel-eslint eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react --save-dev
    
  3. Copy .eslintrc file to your project root directory.

    Recommended: or put ESLint configuration in your package.json file under eslintConfig:

    package.json

    {
        "eslintConfig": {
            "extends": "airbnb",
            "installedESLint": true,
            "parser": "babel-eslint",
            "plugins": [
                "react"
            ],
            "env": {
                "browser": true
            },
            "rules": {
                "semi": ["error", "never"]
            }
        }
    }
    
  4. Configure your editor to read .eslintrc file:

    • Atom

      Install linter and linter-eslint packages and Atom will lint automatically.

    • WebStorm

      Search for 'eslint', then check Enable and set ESLint package to path/to/your/project/node_modules/eslint.

Git pre-commit Hook

Recommended: use git pre-commit hook to run ESLint before committing.

  1. Install pre-commit

    npm install --save-dev pre-commit
    
  2. Add ESLint scripts in your package.json, like below:

    package.json

    {
        "scripts": {
            "lint": "./node_modules/.bin/eslint --global require,window --ext .js src"
        },
        "pre-commit": [
            "lint"
        ]
    }
    
  3. Run git commit to test if pre-commit hook works.

About

Standards for ECMAScript Projects of PALife

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published