Skip to content

Instantly share code, notes, and snippets.

@Dremora
Last active February 8, 2022 11:16
Show Gist options
  • Save Dremora/e1abbe736be924de25c79cb3ffeb2c82 to your computer and use it in GitHub Desktop.
Save Dremora/e1abbe736be924de25c79cb3ffeb2c82 to your computer and use it in GitHub Desktop.
ESLint configuration
const path = require('path');
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname, // required for VS Code
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, // required for TS project references
},
extends: ['./frontend-app'], // or backend
settings: {
'import/resolver': {
typescript: {
project: [
__dirname + '/tsconfig.json',
// add more tsconfigs here if using TS project references
], // required for VS Code
},
},
},
rules: {
'import/no-unused-modules': [
'error',
{
src: [path.join(__dirname, 'src')],
unusedExports: true,
missingExports: true,
ignoreExports: [
// This is for Next.js app, replace with other roots if necessary
// Stories and tests also go here
__dirname + '/src/pages/**/*.tsx',
__dirname + '/src/pages/**/*.ts',
],
},
],
},
};
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/typescript',
'plugin:prettier/recommended',
'./shared',
],
env: {
es6: true,
node: true,
}
};
const restrictedGlobals = require('confusing-browser-globals');
module.exports = {
plugins: ['react-hooks', 'react'],
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:react/jsx-runtime',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:import/typescript',
'plugin:jsx-a11y/recommended',
'plugin:prettier/recommended',
'./shared',
],
env: {
browser: true,
es6: true,
node: true,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'no-restricted-globals': ['error'].concat(restrictedGlobals),
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-filename-extension': ['error', { extensions: ['tsx'] }],
'react/no-array-index-key': 'error',
'react/prefer-stateless-function': 'error',
'react/prop-types': 'off',
'react/self-closing-comp': 'error',
},
};
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
project: './tsconfig.json',
},
plugins: [
'@typescript-eslint',
'import',
'no-type-assertion',
'prettier',
'sort-destructure-keys',
],
settings: {
'import/internal-regex': '^(src|shared)/',
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
},
},
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowNumber: true },
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
'@typescript-eslint/no-use-before-define': [
'error',
{ classes: false, functions: false },
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'no-type-assertion/no-type-assertion': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-cycle': 'error',
'import/no-extraneous-dependencies': 'error',
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'sort-destructure-keys/sort-destructure-keys': 'error',
'sort-imports': [
'error',
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment