Skip to content

Instantly share code, notes, and snippets.

@DemonDaddy22
Last active August 22, 2021 13:05
Show Gist options
  • Save DemonDaddy22/b4cfc02ccb8aba3eefdf572ac1bfb744 to your computer and use it in GitHub Desktop.
Save DemonDaddy22/b4cfc02ccb8aba3eefdf572ac1bfb744 to your computer and use it in GitHub Desktop.
ESLint Rules used by me across my various projects. First file is the one that I use for backend stuff and second one for front-end part. To enforce these rules, I also add prettier plugin in my projects and specify some basic config rules to setup prettier.
module.exports = {
parser: '@babel/eslint-parser',
env: {
browser: true,
es2021: true,
node: true,
},
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
requireConfigFile: false,
},
extends: ['prettier'],
plugins: ['prettier'],
rules: {
'prettier/prettier': 2,
semi: 2,
'comma-dangle': 0,
'no-unused-vars': 1,
'no-undef': 1,
'no-unexpected-multiline': 1,
'no-debugger': 2,
'no-alert': 1,
'no-console': 1,
'no-await-in-loop': 1,
'no-return-assign': ['error', 'except-parens'],
'no-unused-expressions': [2, { allowTaggedTemplates: true }],
'import/prefer-default-export': 0,
import: 0,
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
eqeqeq: 1,
'array-bracket-spacing': 1,
'object-curly-spacing': [1, 'always'],
'object-curly-newline': [
1,
{
ObjectExpression: {
multiline: true,
minProperties: 3,
consistent: false,
},
},
],
camelcase: 1,
indent: 2,
'max-len': [
2,
{
code: 120,
tabWidth: 4,
ignoreTemplateLiterals: true,
},
],
'arrow-spacing': [2, { before: true, after: true }],
'comma-spacing': [2, { before: false, after: true }],
},
};
module.exports = {
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
env: {
es6: true,
browser: true,
},
globals: {},
extends: ['prettier'],
plugins: ['react', 'react-hooks', 'prettier'],
rules: {
'prettier/prettier': 2,
semi: 2,
'comma-dangle': 0,
'react/jsx-uses-vars': 1,
'no-unused-vars': 1,
'no-undef': 0,
'no-unexpected-multiline': 1,
'no-debugger': 2,
'no-alert': 1,
'no-console': 1,
'no-await-in-loop': 1,
'no-return-assign': ['error', 'except-parens'],
'no-unused-expressions': [2, { allowTaggedTemplates: true }],
'import/prefer-default-export': 0,
import: 0,
'react/require-default-props': 0,
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
eqeqeq: 1,
'array-bracket-spacing': 1,
'object-curly-spacing': [1, 'always'],
'object-curly-newline': [
1,
{
ObjectExpression: {
multiline: true,
minProperties: 3,
consistent: false,
},
},
],
camelcase: 1,
'template-curly-spacing': 'off',
indent: ['error', 4, { ignoredNodes: ['TemplateLiteral'] }],
'max-len': [
2,
{
code: 120,
tabWidth: 4,
ignoreTemplateLiterals: true,
},
],
},
settings: {
'import/resolver': 'webpack',
react: {
createClass: 'createReactClass',
pragma: 'React',
fragment: 'Fragment',
version: 'detect',
flowVersion: '0.53',
},
propWrapperFunctions: [
'forbidExtraProps',
{ property: 'freeze', object: 'Object' },
{ property: 'myFavoriteWrapper' },
],
linkComponents: ['Hyperlink', { name: 'Link', linkAttribute: 'to' }],
},
};
module.exports = {
tabWidth: 4,
semi: true,
singleQuote: true,
trailingComma: 'es5',
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment