Skip to content

Instantly share code, notes, and snippets.

@mqklin
Created June 8, 2022 13:49
Show Gist options
  • Save mqklin/029d6e0d3aec6c89dec98557c8cef6fb to your computer and use it in GitHub Desktop.
Save mqklin/029d6e0d3aec6c89dec98557c8cef6fb to your computer and use it in GitHub Desktop.
/* global module, __dirname */
/* eslint-disable import/no-commonjs, import/no-nodejs-modules */
const path = require('path');
module.exports = {
globals: {
require: 'readonly',
process: 'readonly',
// browser env
Promise: 'readonly',
document: 'readonly',
console: 'readonly',
window: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
navigator: 'readonly',
FormData: 'readonly',
FileReader: 'readonly',
Image: 'readonly',
URLSearchParams: 'readonly',
getComputedStyle: 'readonly',
Symbol: 'readonly',
IntersectionObserver: 'readonly',
File: 'readonly',
Set: 'readonly',
Proxy: 'readonly',
structuredClone: 'readonly',
},
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false,
babelOptions: require(path.resolve(__dirname, 'webpack-configs/app.js'))({SENTRY_ENV: 'atom'}).module.rules[0].use.options,
},
plugins: [
'react',
'import',
'babel',
'brackets',
'react-hooks',
'unicorn',
],
settings: {
'import/resolver': {
node: true,
webpack: {
config: path.resolve(__dirname, 'webpack-configs/dev.js'),
},
},
react: {
version: 'detect',
},
propWrapperFunctions: ['forbidExtraProps'],
},
rules: {
'valid-typeof': ['error', {requireStringLiterals: true}],
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': ['error'],
'brace-style': ['error', 'stroustrup'],
'comma-spacing': ['error'],
'eol-last': ['error', 'always'],
'func-call-spacing': ['error'],
'jsx-quotes': ['error'],
'key-spacing': ['error'],
'block-spacing': ['error'],
'keyword-spacing': ['error'],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['error', 'always', {exceptAfterSingleLine: true}],
'no-case-declarations': ['error'],
'no-console': ['error'],
'no-const-assign': ['error'],
'no-debugger': ['error'],
'no-dupe-args': ['error'],
'no-eval': ['error'],
'no-dupe-class-members': ['error'],
'no-dupe-keys': ['error'],
'no-duplicate-case': ['error'],
'no-duplicate-imports': ['error'],
'no-empty': ['error', {allowEmptyCatch: true}],
'no-extra-boolean-cast': ['error', {enforceForLogicalOperands: true}],
'no-extra-parens': ['error', 'all', {ignoreJSX: 'all'}],
'no-extra-semi': ['error'],
'no-global-assign': ['error'],
'prefer-destructuring': ['error', {VariableDeclarator: {array: false, object: true}, AssignmentExpression: {array: true, object: false}}],
'no-implicit-coercion': ['error', {disallowTemplateShorthand: true}],
'no-sequences': ['error', {allowInParentheses: false}],
radix: ['error'],
'arrow-body-style': ['error'],
'dot-location': ['error', 'property'],
'no-irregular-whitespace': ['error'],
'no-mixed-spaces-and-tabs': ['error'],
'no-multi-spaces': ['error'],
'no-constant-condition': ['error'],
'getter-return': ['error'],
'no-useless-escape': ['error'],
'no-control-regex': ['error'],
// 'no-prototype-builtins': ['error'],
'no-multi-str': ['error'],
'no-multiple-empty-lines': ['error', {max: 2, maxEOF: 1}],
'no-redeclare': ['error'],
'no-sparse-arrays': ['error'],
'no-await-in-loop': ['error'],
'no-self-assign': ['error'],
'no-whitespace-before-property': ['error'],
'no-trailing-spaces': ['error'],
'no-undef': ['error'],
'no-unexpected-multiline': ['error'],
'no-unreachable': ['error'],
'object-property-newline': ['error', {allowAllPropertiesOnSameLine: true}],
'no-unused-expressions': ['error', {allowTaggedTemplates: true, allowTernary: true, enforceForJSX: true}],
'no-unused-vars': ['error', {vars: 'all', ignoreRestSiblings: true, args: 'all', argsIgnorePattern: '^_+$', caughtErrors: 'all'}],
'no-use-before-define': ['error', {functions: false, classes: false}],
'no-var': ['error'],
'no-script-url': ['error'],
'no-multi-assign': ['error'],
'no-func-assign': ['error'],
'space-unary-ops': ['error'],
'no-invalid-regexp': ['error'],
'prefer-regex-literals': ['error'],
'prefer-template': ['error'],
'template-curly-spacing': ['error'],
'for-direction': ['error'],
'object-curly-spacing': ['error', 'never'],
'prefer-const': ['error'],
'prefer-rest-params': ['error'],
'quote-props': ['error', 'as-needed'],
'space-before-blocks': ['error'],
'operator-assignment': ['error'],
'use-isnan': ['error'],
'no-loss-of-precision': ['error'],
'dot-notation': ['error'],
'no-useless-computed-key': ['error'],
'space-infix-ops': ['error'],
'space-in-parens': ['error'],
'no-useless-rename': ['error'],
'array-bracket-spacing': ['error'],
'computed-property-spacing': ['error'],
'no-async-promise-executor': ['error'],
'max-nested-callbacks': ['error'],
'no-return-await': ['error'],
'prefer-promise-reject-errors': ['error'],
// 'prefer-object-has-own': ['error'],
eqeqeq: ['error'],
'semi-spacing': ['error'],
'no-unsafe-optional-chaining': ['error'],
'no-useless-backreference': ['error'],
'no-nonoctal-decimal-escape': ['error'],
'no-octal-escape': ['error'],
'no-undefined': ['error'],
'no-extend-native': ['error'],
'no-invalid-this': ['error'],
curly: ['error'],
indent: ['error', 2, {SwitchCase: 1, flatTernaryExpressions: true}],
quotes: ['error', 'single'],
'prefer-exponentiation-operator': ['error'],
semi: ['error', 'always', {omitLastInOneLineBlock: true}],
'space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
}],
'no-constructor-return': ['error'],
'no-dupe-else-if': ['error'],
'no-setter-return': ['error'],
'no-restricted-syntax': [
'error',
{
selector: 'AssignmentExpression[left.object.name=\'window\']',
message: 'Don\'t write to window!',
},
],
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
}],
'react-hooks/rules-of-hooks': 'error',
'react/no-unused-state': 'error',
'react/no-unused-prop-types': 'error',
'react/prop-types': 'error',
'react/jsx-sort-props': ['error', {reservedFirst: true}],
'react/sort-prop-types': ['error', {ignoreCase: true}],
'react/jsx-curly-brace-presence': ['error', {props: 'never', children: 'never'}],
'react/jsx-no-useless-fragment': 'error',
'react/jsx-pascal-case': ['error', {allowAllCaps: true}],
'react/no-danger-with-children': 'error',
// 'react/jsx-no-constructed-context-values': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-equals-spacing': 'error',
'react/jsx-tag-spacing': ['error', {beforeSelfClosing: 'never'}],
'react/jsx-no-target-blank': 'error',
'react/jsx-no-undef': ['error', {allowGlobals: true}],
'react/jsx-no-duplicate-props': 'error',
'react/jsx-key': 'error',
'react/jsx-first-prop-new-line': ['error'],
'react/jsx-indent': ['error', 2, {indentLogicalExpressions: true}],
'react/jsx-indent-props': ['error', 2],
'react/jsx-curly-spacing': [2, {children: true}],
'react/jsx-wrap-multilines': ['error', {
declaration: 'parens-new-line',
assignment: 'parens-new-line',
return: 'parens-new-line',
arrow: 'parens-new-line',
condition: 'parens-new-line',
}],
'import/no-unresolved': [2, {commonjs: true}],
'import/named': 'error',
'import/default': 'error',
'import/no-named-as-default': 'error',
// 'import/no-unused-modules': ['error', {unusedExports: true}],
// 'import/order': ['error', {groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object']}],
'import/no-nodejs-modules': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-cycle': 'error',
'import/no-self-import': 'error',
'import/first': 'error',
'import/no-commonjs': ['error', {allowRequire: true}],
'import/dynamic-import-chunkname': 'error',
'babel/semi': 'error',
'brackets/array-bracket-newline': 'error',
'brackets/conditional-parens-newline': 'error',
'brackets/func-parens-newline': 'error',
'brackets/object-curly-newline': 'error',
'unicorn/no-array-callback-reference': 'error',
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment