Skip to content

Commit

Permalink
Update linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvberg authored and alharris-at committed Jun 30, 2022
1 parent a900c11 commit 7d2ac97
Showing 1 changed file with 12 additions and 78 deletions.
90 changes: 12 additions & 78 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const dictionary = require('./.eslint-dictionary.json');
/**
* README if you have come here because you are sick and tired of some rule being on your case all the time:
* If you are trying to modify a rule for normal code, see the docs for each of the lint plugins we are using in the "rules" section.
* If you are trying to add a word to spellcheck: run `yarn addwords <word1> <word2> ...`
* If you are trying to ignore certain files from spellchecking, see the "overrides" section
* If you are trying to modify rules that run in test files, see the "overrides" section
* If you are trying to ignore certain files from linting, see "ignorePatterns" at the bottom of the file
Expand Down Expand Up @@ -43,18 +41,6 @@ module.exports = {
rules: {
// NOTE: This config should only specify rules as "errors" or "off". Over time "warnings" invariably become the same as "off".

// Spellcheck rules
// Docs: https://www.npmjs.com/package/eslint-plugin-spellcheck
'spellcheck/spell-checker': ['error', {
lang: 'en_US',
skipWords: dictionary,
skipIfMatch: [
'http://[^s]*',
'^[-\\w]+/[-\\w\\.]+$', //For MIME Types
],
minLength: 4,
}],

// Disables double quote error when using single quotes within string for readability
// https://eslint.org/docs/rules/quotes#avoidescape
'quotes': ['error', 'single', { 'avoidEscape': true }],
Expand All @@ -78,11 +64,12 @@ module.exports = {
},
],
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/method-signature-style': ['error', 'property'],

// Some ESLint rules conflict with the corresponding TS rule. These ESLint rules are turned off in favor of the corresponding TS rules
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': 'error',
'no-unused-vars': 'off',
Expand All @@ -104,7 +91,7 @@ module.exports = {

// JSDoc Rules
// Docs here: https://www.npmjs.com/package/eslint-plugin-jsdoc
'jsdoc/require-jsdoc': ['error', {
'jsdoc/require-jsdoc': ['warn', {
publicOnly: true,
require: {
ClassDeclaration: true,
Expand All @@ -120,9 +107,9 @@ module.exports = {
}],
'jsdoc/require-description': ['error', { contexts: ['any'] }
],
'jsdoc/require-param': 'off',
'jsdoc/require-param': 'warn',
'jsdoc/require-param-description': 'error',
'jsdoc/require-returns': 'off',
'jsdoc/require-returns': 'warn',
'jsdoc/require-returns-description': 'error',
'jsdoc/check-param-names': 'error',

Expand All @@ -142,17 +129,16 @@ module.exports = {
'max-classes-per-file': 'error',
'no-lonely-if': 'error',
'no-unneeded-ternary': 'error',
'no-use-before-define': 'off',
'no-use-before-define': 'error',
'consistent-return': 'error',
'no-bitwise': 'error',
'yoda': 'error',
'no-var': 'error',
'strict': 'error',
'spaced-comment': ['error', 'always'],
'no-new': 'error',
'no-useless-constructor': 'off',
'no-underscore-dangle': 'off',
'no-template-curly-in-string': 'off',
'no-underscore-dangle': 'error',
'no-template-curly-in-string': 'error',
'no-plusplus': 'off',

// same as air-bnb default with the exception of allowing for...of
Expand All @@ -173,11 +159,11 @@ module.exports = {
],

// function style
'arrow-parens': ['error', 'as-needed'],
'arrow-parens': ['error', 'always'],
'func-style': ['error', 'expression'],
'prefer-arrow/prefer-arrow-functions': ['error', { disallowPrototype: true }],
// yes I know these are all supposed to be errors, but this one requires too much functional refactoring at the moment
// we should still aim to keep funcitons small moving forward
// we should still aim to keep functions small moving forward
'max-lines-per-function': ['warn', {
max: 50,
skipBlankLines: true,
Expand All @@ -186,13 +172,6 @@ module.exports = {
'max-depth': ['error', 4],
},
overrides: [
{
// Add files to this list that shouldn't be spellchecked
files: ['.eslintrc.js'],
rules: {
'spellcheck/spell-checker': 'off',
},
},
{
// edit rules here to modify test linting
files: ['__tests__/**', '*.test.ts'],
Expand All @@ -209,7 +188,6 @@ module.exports = {
// (note that only .js, .jsx, .ts, and .tsx files are linted in the first place)
ignorePatterns: [
'.eslintrc.js',
'scripts/',
'node_modules',
'dist',
'build',
Expand All @@ -220,9 +198,7 @@ module.exports = {
'amplify-velocity-template',

// Project specific excludes
'/cypress',
'/packages/amplify-appsync-simulator/public',
'/packages/amplify-cli/scripts/post-install.js',

// Ignore project/file templates
'function-template-dir',
Expand All @@ -232,49 +208,7 @@ module.exports = {
'/packages/amplify-e2e-tests/overrides',

// Ignore lib directory of typescript packages until all packages are migrated to typescript
'/packages/amplify-*-function-*/lib',
'/packages/amplify-appsync-simulator/lib',
'/packages/amplify-category-api/lib',
'/packages/amplify-category-auth/lib',
'/packages/amplify-category-function/lib',
'/packages/amplify-category-geo/lib',
'/packages/amplify-category-storage/lib',
'/packages/amplify-cli-npm/lib',
'/packages/amplify-cli-core/lib',
'/packages/amplify-cli/lib',
'/packages/amplify-cli-logger/lib',
'/packages/amplify-e2e-core/lib',
'/packages/amplify-function-plugin-interface/lib',
'/packages/amplify-graphql-schema-test-library/lib',
'/packages/amplify-headless-interface/lib',
'/packages/amplify-migration-tests/lib',
'/packages/amplify-prompts/lib',
'/packages/amplify-provider-awscloudformation/lib',
'/packages/amplify-storage-simulator/lib',
'/packages/amplify-ui-tests/lib',
'/packages/amplify-util-headless-input/lib',
'/packages/amplify-util-mock/lib',
'/packages/graphql-*-transformer/lib',
'/packages/graphql-mapping-template/lib',
'/packages/graphql-transformer-*/lib',
'/packages/amplify-headless-interface/lib',
'/packages/amplify-util-headless-input/lib',
'/packages/amplify-util-uibuilder/lib',
'/packages/amplify-graphql-docs-generator/lib',
'/packages/amplify-graphql-*transformer*/lib',
'/packages/amplify-graphql-types-generator/lib',
'/packages/amplify-provider-awscloudformation/lib',
'/packages/amplify-console-integration-tests/lib',
'/packages/amplify-cli-extensibility-helper/lib',
'/packages/amplify-category-auth/resources/auth-custom-resource',
'/packages/amplify-category-custom/lib',
'/packages/amplify-category-custom/resources',
'/packages/amplify-console-hosting/lib/',
'/packages/amplify-container-hosting/lib/',
'/packages/amplify-category-predictions/lib',
'/packages/amplify-category-analytics/lib',
'/amplify-category-interactions/lib',
'/packages/amplify-category-custom/src/utils/generate-cfn-from-cdk.ts',
'/packages/*/lib',

// Ignore CHANGELOG.md files
'/packages/*/CHANGELOG.md',
Expand Down

0 comments on commit 7d2ac97

Please sign in to comment.