rogerxu / rogerxu.github.io

Roger Xu's Blog
2 stars 2 forks source link

ESLint #111

Open rogerxu opened 7 years ago

rogerxu commented 7 years ago

ESLint - Pluggable JavaScript linter

rogerxu commented 7 years ago

Configuration

Configuring ESLint - ESLint - Pluggable JavaScript linter

If there are multiple configuration files in the same directory, ESLint will only use one. The priority order is:

  1. .eslintrc.js
  2. .eslintrc.yaml
  3. .eslintrc.yml
  4. .eslintrc.json - ESLint’s JSON files also allow JavaScript-style comments.
  5. .eslintrc - Deprecated
  6. package.json

.eslintrc.json

{
  "root": true,
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "script",
    "ecmaFeatures": {
      "impliedStrict": true
    }
  },
  "env": {
    "node": true,
    "es6": true
  },
  "globals": {},
  "extends": "eslint:recommended",
  "rules": {}
}
rogerxu commented 7 years ago

Rules

List of available rules - ESLint - Pluggable JavaScript linter

rogerxu commented 5 years ago

Possible Errors

rogerxu commented 5 years ago

Best Practices

Strict Mode

rogerxu commented 5 years ago

Variables

rogerxu commented 5 years ago

Node.js and CommonJS

rogerxu commented 5 years ago

Stylistic Issues

rogerxu commented 5 years ago

ECMAScript 6

rogerxu commented 5 years ago

VS Code Extension

Microsoft/vscode-eslint: VSCode extension to integrate eslint into VSCode

Configuration

Node.js API - ESLint - Pluggable JavaScript linter

.vscode/settings.json

{
  "eslint.options": {
    "ignorePath": "app/.eslintignore",
    "rulePaths": ["app/node_modules/@sap/di.code-validation.js/src/defaultConfig/fioriCustomRules/.eslintrules"]
  },
}