Skip to content

Instantly share code, notes, and snippets.

@wfpaisa
Last active March 9, 2019 19:06
Show Gist options
  • Save wfpaisa/5762e2925e211cd100db976398fa4924 to your computer and use it in GitHub Desktop.
Save wfpaisa/5762e2925e211cd100db976398fa4924 to your computer and use it in GitHub Desktop.
ESLINT
// FOR VUE
module.exports = {
"root": true,
"extends": [
"plugin:vue/recommended", // ver-> https://alligator.io/vuejs/vue-eslint-plugin/
// "plugin:prettier/recommended",
"eslint:recommended"
],
"rules": {
// Disallow the use of debugger
"no-debugger": 0,
// Disallow the use of alert, confirm, and prompt
"no-alert": 0,
// Disallow unused variables
"no-unused-vars": [
1,
{
"ignoreSiblings": true,
"argsIgnorePattern": "res|next|^err"
}
],
// Require const declarations for variables that are never reassigned after declared
// "prefer-const": [
// "error",
// {
// "destructuring": "all"
// }
// ],
// Require destructuring from arrays and/or objects
"prefer-destructuring": ["error", {
"object": false,
"array": false
}],
// require braces around arrow function bodies
"arrow-body-style": [
2,
"as-needed"
],
// disallow unused expressions
"no-unused-expressions": [
2,
{
"allowTaggedTemplates": true
}
],
// disallow reassigning function parameters
"no-param-reassign": [
2,
{
"props": false
}
],
// disallow the use of console
"no-console": 0,
// require or disallow named function expressions
"func-names": 0,
// enforce consistent spacing before function definition opening parenthesis
"space-before-function-paren": 0,
// require or disallow trailing commas
"comma-dangle": 0,
// enforce a maximum line length (80)
"max-len": 0,
// disallow dangling underscores in identifiers
"no-underscore-dangle": 0,
// require return statements to either always or never specify values
"consistent-return": 0,
// enforce the consistent use of the radix argument when using parseInt()
"radix": 0,
// disallow variable declarations from shadowing variables declared in the outer scope
"no-shadow": [
2,
{
"hoist": "all",
"allow": [
"resolve",
"reject",
"done",
"next",
"err",
"error"
]
}
],
// enforce the consistent use of either backticks, double, or single quotes
"quotes": [
2,
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
//'no-use-before-define': 0, //disallow the use of variables before they are defined
// support linting of ES2015+ (ES6+) import/export syntax,
"import": 0,
// When there is only a single export from a module, prefer using default export over named export.
"import/prefer-default-export": 0,
// A list of file extensions that will be parsed as modules and inspected for exports.
"import/extensions": 0,
// //---------- Prettier ----------
// "prettier/prettier": [
// "error",
// {
// "trailingComma": "es5", // commas at the end ES5 (objects, arrays, etc.)
// "singleQuote": true, // Use single quotes instead of double quotes.
// "printWidth": 80, // Width of the column before breaking it
// }
// ],
}
}
module.exports = {
"extends": [
//"react-app", // only if is `create-react-app` application
"airbnb",
"prettier",
"prettier/react"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"impliedStrict": true,
"classes": true
}
},
"env": {
"browser": true,
"node": true,
"jquery": true,
"jest": true
},
"rules": {
// Disallow the use of debugger
"no-debugger": 0,
// Disallow the use of alert, confirm, and prompt
"no-alert": 0,
// Disallow unused variables
"no-unused-vars": [
1,
{
"ignoreSiblings": true,
"argsIgnorePattern": "res|next|^err"
}
],
// Require const declarations for variables that are never reassigned after declared
// "prefer-const": [
// "error",
// {
// "destructuring": "all"
// }
// ],
// Require destructuring from arrays and/or objects
"prefer-destructuring": ["error", {
"object": false,
"array": false
}],
// require braces around arrow function bodies
"arrow-body-style": [
2,
"as-needed"
],
// disallow unused expressions
"no-unused-expressions": [
2,
{
"allowTaggedTemplates": true
}
],
// disallow reassigning function parameters
"no-param-reassign": [
2,
{
"props": false
}
],
// disallow the use of console
"no-console": 0,
// require or disallow named function expressions
"func-names": 0,
// enforce consistent spacing before function definition opening parenthesis
"space-before-function-paren": 0,
// require or disallow trailing commas
"comma-dangle": 0,
// enforce a maximum line length (80)
"max-len": 0,
// disallow dangling underscores in identifiers
"no-underscore-dangle": 0,
// require return statements to either always or never specify values
"consistent-return": 0,
// enforce the consistent use of the radix argument when using parseInt()
"radix": 0,
// disallow variable declarations from shadowing variables declared in the outer scope
"no-shadow": [
2,
{
"hoist": "all",
"allow": [
"resolve",
"reject",
"done",
"next",
"err",
"error"
]
}
],
// enforce the consistent use of either backticks, double, or single quotes
"quotes": [
2,
"single",
{
"avoidEscape": true,
"allowTemplateLiterals": true
}
],
// support linting of ES2015+ (ES6+) import/export syntax,
"import": 0,
// When there is only a single export from a module, prefer using default export over named export.
"import/prefer-default-export": 0,
// A list of file extensions that will be parsed as modules and inspected for exports.
"import/extensions": 0,
// ---------- React ----------
// DisplayName allows you to name your component. This name is used by React in debugging messages.
"react/display-name": 1,
// Prevent using Array index in key props
"react/no-array-index-key": 0,
// Prevent missing React when using JSX
"react/react-in-jsx-scope": 0,
// Enforce stateless React Components to be written as a pure function
"react/prefer-stateless-function": 0,
// Forbid certain propTypes
"react/forbid-prop-types": 0,
// Prevent invalid characters from appearing in markup
"react/no-unescaped-entities": 0,
// Enforce a defaultProps definition for every prop that is not a required prop
"react/require-default-props": 0,
// Prevent missing props validation in a React component definition
// avoid error in (props.query) [https://github.com/yannickcr/eslint-plugin-react/issues/1257]
// "react/prop-types": [
// "enabled",
// {
// "ignore": "ignore",
// "customValidators": "customValidator"
// }
// ],
// ---------- JSX ----------
// allow emoji (<span role="img" aria-label="Panda">🐼</span>)
"jsx-a11y/accessible-emoji": 0,
// Restrict file extensions that may contain JSX
"react/jsx-filename-extension": [
1,
{
"extensions": [
".js",
".jsx"
]
}
],
// Enforce all anchors are valid, navigable elements.
"jsx-a11y/anchor-is-valid": [
"warn",
{
"aspects": [
"invalidHref"
]
}
],
// ---------- Prettier ----------
"prettier/prettier": [
"error",
{
"trailingComma": "es5", // commas at the end ES5 (objects, arrays, etc.)
"singleQuote": true, // Use single quotes instead of double quotes.
"printWidth": 80, // Width of the column before breaking it
"jsxBracketSameLine": true // place the > symbol at the end of the last line instead of a new line
}
],
},
"plugins": [
"prettier"
]
};

If is a CRA (Create React APP)

Uncomment in Extends react-app and add:

yarn add --dev --exact prettier eslint-plugin-prettier eslint-config-airbnb eslint-plugin-import eslint-config-prettier eslint-plugin-jsx-a11y

Regular app

install this dependencies:

npm i -D babel-eslint eslint eslint-config-airbnb eslint-config-prettier eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react prettier

For vue

https://alligator.io/vuejs/vue-eslint-plugin/ https://alligator.io/vuejs/vue-eslint-prettier/ npm install eslint eslint-plugin-vue eslint-plugin-prettier eslint-config-prettier --save-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment