Initial Commit, eslint rules

This commit is contained in:
RingOfStorms (Joshua Bell) 2020-12-22 22:21:11 -06:00
commit 7b9db430ea
16 changed files with 2365 additions and 0 deletions

8
src/base/rules/eslint.js Normal file
View file

@ -0,0 +1,8 @@
module.exports = {
// === DISABLED ===
// ==== ERRORS ====
curly: 'error',
'sort-imports': ['error', {
ignoreDeclarationSort: true
}],
};

18
src/base/rules/import.js Normal file
View file

@ -0,0 +1,18 @@
module.exports = {
// === DISABLED ===
// recommended is error, typescript covers this and import/named error has issues
'import/named': 'off',
// on by default, we do NOT want export default ever.
'import/default': 'off',
// ==== ERRORS ====
// We will not use plugin:import/warnings because we want errors
'import/no-duplicates': 'error',
'import/order': ['error', { 'newlines-between': 'always' }],
// This will differ for every project and may not even need any settings
// COPY this to rules of project:
// `"import/no-internal-modules": ["error", { allow: ["uuid/**", "@nestjs/**"] }],`
'import/no-internal-modules': ['error'],
'import/no-cycle': 'error',
'import/no-mutable-exports': 'error',
'import/no-default-export': 'error',
};

View file

@ -0,0 +1,6 @@
module.exports = {
// === DISABLED ===
// ==== ERRORS ====
// recommended is warn => enforcing error
'new-with-error/new-with-error': 'error',
};

View file

@ -0,0 +1,5 @@
module.exports = {
// === DISABLED ===
// ==== ERRORS ====
'prettier/prettier': 'error',
};

View file

@ -0,0 +1,20 @@
module.exports = {
// === DISABLED ===
// We like parameter properties, so turn them on by turning off this default inverse rule.
'@typescript-eslint/no-parameter-properties': 'off',
// ==== ERRORS ====
// recommended is warn => enforcing error
'@typescript-eslint/no-unused-vars': 'error',
// recommended is warn => enforcing error
'@typescript-eslint/no-explicit-any': 'error',
// recommended is warn => enforcing error
'@typescript-eslint/explicit-function-return-type': ['error', {
allowExpressions: true,
allowTypedFunctionExpressions: true
}],
// recommended does not configure no-public
'@typescript-eslint/explicit-member-accessibility': ['error', {
accessibility: 'no-public',
}],
'@typescript-eslint/no-extraneous-class': 'error',
};

View file

@ -0,0 +1,10 @@
module.exports = {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
typescript: {
alwaysTryTypes: false,
},
},
};

12
src/react/overrides.js Normal file
View file

@ -0,0 +1,12 @@
module.exports = [
{
files: ['**/*.tsx'],
rules: {
// [Plugin] react - disable prop type checks in typescript since we use interfaces
'react/prop-types': 'off',
// Allow ts-ignore in test files for easily faking data and objects
'@typescript-eslint/ban-ts-ignore': 'off',
},
},
];

6
src/react/rules/react-hooks.js vendored Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
// === DISABLED ===
// ==== ERRORS ====
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
};

23
src/react/rules/react.js vendored Normal file
View file

@ -0,0 +1,23 @@
module.exports = {
// === DISABLED ===
// This does not play nice with React.memo()
'react/display-name': 'off',
// ==== ERRORS ====
'react/no-access-state-in-setstate': 'error',
'react/no-redundant-should-component-update': 'error',
'react/no-typos': 'error',
'react/no-unsafe': 'error',
'react/self-closing-comp': 'error',
'react/jsx-no-bind': 'error',
'react/jsx-max-depth': ['error', { max: 5 }],
'react/jsx-curly-brace-presence': ['error', 'never'],
'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',
logical: 'parens-new-line',
prop: 'parens-new-line'
}],
};

6
src/react/settings/react.js vendored Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
react: {
pragma: 'React',
version: 'detect',
},
};