Skip to content

Latest commit

 

History

History
132 lines (107 loc) · 2.41 KB

README.MD

File metadata and controls

132 lines (107 loc) · 2.41 KB

eslint-plugin-chowa-standard

npm npm license

Chowa project javascript and typescript syntax standard

Install

npm i eslint-plugin-chowa-standard --save-dev

Usage

If you don't have eslint installed

npm i eslint eslint-loader eslint-friendly-formatter  --save-dev

webpack loader

module.exports = {
    module: {
        rules: [{
            test: /\.(j|t)sx?$/,
            enforce: 'pre',
            use: [
                {
                    loader: 'eslint-loader',
                    options: {
                        emitWarning: true,
                        emitError: true,
                        formatter: require('eslint-friendly-formatter')
                    }
                }
            ]
        }]
    }
}

eslintrc

{
    extends: [
        'plugin:chowa-standard/recommended'
    ]
}

Configuration

React

Install plugin

npm i eslint-plugin-react --save-dev

eslintrc

{
    extends: [
        'plugin:react/recommended',
        'plugin:chowa-standard/recommended'
    ],
    plugins: [
        'react'
    ],
    env: {
        node: false,
        browser: true,
        es6: true
    },
    parserOptions: {
        ecmaVersion: 2017,
        sourceType: 'module',
        jsx: true
    },
    settings: {
        react: {
            pragma: 'React',
            version: 'detect'
        }
    }
}

Typescript

Install plugin and parser

npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev

eslintrc

{
    parser: '@typescript-eslint/parser',
    extends: [
        'plugin:@typescript-eslint/eslint-recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:chowa-standard/recommended'
    ],
    plugins: [
        '@typescript-eslint'
    ],
    env: {
        node: true,
        es6: true
    },
    parserOptions: {
        ecmaVersion: 2017,
        sourceType: 'module'
    }
}