Site Tools


javascript:eslint
npx mrm gitignore prettier jest
npx install-peerdeps --dev eslint-config-airbnb-base
npm i -D eslint-config-prettier eslint-plugin-prettier eslint-plugin-node babel-eslint
npm i -D @babel/core @babel/preset-env @babel/plugin-transform-modules-commonjs
.eslintrc.js
module.exports = {
  parser: 'babel-eslint',
 
  env: {
    commonjs: true,
    jest: true,
    es6: true,
    node: true,
    browser: true,
  },
  extends: ['plugin:node/recommended', 'airbnb-base', 'plugin:prettier/recommended'],
  plugins: ['prettier'],
  rules: {
    'prettier/prettier': ['error'],
    'no-undef': 'error',
    'no-unused-vars': 'warn',
    'no-console': 'off',
  },
};
prettier.config.js
module.exports = {
  $schema: 'http://json.schemastore.org/prettierrc',
  arrowParens: 'always',
  printWidth: 88,
  singleQuote: true,
  tabWidth: 2,
  trailingComma: 'all',
  overrides: [
    {
      files: ['*.yaml', '*.yml'],
      options: {
        singleQuote: false,
      },
    },
  ],
};
.editorconfig
[*.{js,ts}]
charset = utf-8
indent_style = space
indent_size = 2
 
[Makefile]
indent_style = tab
 
[*.{json,yaml,yml}]
indent_style = space
indent_size = 2
package.json
{
  {
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ],
    "transform": {
      "^.+\\.[t|j]sx?$": "babel-jest"
    },
    "setupFiles": [
      "./test/jestsetup.js"
    ]
  }
}
.babelrc
{
  "presets": ["@babel/preset-env"],
  "env": {
    "test": {
      "plugins": ["@babel/plugin-transform-modules-commonjs"]
    }
  }
}
javascript/eslint.txt · Last modified: 2020-10-03 by dcai