Skip to content

Commit

Permalink
fix: included consistent-return, no-restricted-syntax, and quote rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sdstolworthy committed Dec 14, 2022
1 parent 4cd6709 commit 6ab3253
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 113 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ indent_size = 2
trim_trailing_spaces = true
insert_final_newline = true
max_line_length = 140
quote_type = single
239 changes: 130 additions & 109 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const dictionary = require("./.eslint-dictionary.json");
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.
Expand All @@ -9,161 +9,182 @@ const dictionary = require("./.eslint-dictionary.json");
*/
module.exports = {
root: true,
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
env: {
es6: true,
node: true,
jest: true,
jest: true
},
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
project: ["tsconfig.base.json", "packages/amplify-cli/tsconfig.json"],
sourceType: 'module', // Allows for the use of imports
project: ['tsconfig.base.json', 'packages/amplify-cli/tsconfig.json'],
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
arrowFunctions: true,
modules: true,
module: true,
},
module: true
}
},
plugins: ["@typescript-eslint", "spellcheck", "import", "jsdoc", "prefer-arrow"],
plugins: ['@typescript-eslint', 'spellcheck', 'import', 'jsdoc', 'prefer-arrow'],
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
typescript: {},
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx']
},
'import/resolver': {
typescript: {}
}
},
rules: {
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-misused-promises": "error",
"no-bitwise": "warn",
"spellcheck/spell-checker": [
"warn",
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'no-bitwise': 'warn',
'consistent-return': 'error',
'no-restricted-syntax': [
'error',
{
lang: "en_US",
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.'
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
}
],

quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'spellcheck/spell-checker': [
'warn',
{
lang: 'en_US',
skipWords: dictionary,
skipIfMatch: [
"http://[^s]*",
"^[-\\w]+/[-\\w\\.]+$", //For MIME Types
'http://[^s]*',
'^[-\\w]+/[-\\w\\.]+$' //For MIME Types
],
minLength: 4,
},
],
minLength: 4
}
]
},
overrides: [
{
// Add files to this list that shouldn't be spellchecked
files: [".eslintrc.js"],
files: ['.eslintrc.js'],
rules: {
"spellcheck/spell-checker": "off",
},
'spellcheck/spell-checker': 'off'
}
},
{
// edit rules here to modify test linting
files: ["__tests__/**", "*.test.ts", "**/amplify-e2e-tests/**"],
plugins: ["jest"],
extends: ["plugin:jest/recommended"],
files: ['__tests__/**', '*.test.ts', '**/amplify-e2e-tests/**'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
"@typescript-eslint/unbound-method": "off",
"jest/unbound-method": "error",
"@typescript-eslint/no-explicit-any": "off",
"spellcheck/spell-checker": "off"
},
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'spellcheck/spell-checker': 'off'
}
},
{
// disable spell checker in tests
files: ["**/__tests__/**", "*.test.ts", "packages/amplify-e2e-*/**", "**/test/**"],
plugins: ["jest"],
extends: ["plugin:jest/recommended"],
files: ['**/__tests__/**', '*.test.ts', 'packages/amplify-e2e-*/**', '**/test/**'],
plugins: ['jest'],
extends: ['plugin:jest/recommended'],
rules: {
"spellcheck/spell-checker": "off"
},
'spellcheck/spell-checker': 'off'
}
}
],
// Files / paths / globs that shouldn't be linted at all
// (note that only .js, .jsx, .ts, and .tsx files are linted in the first place)
ignorePatterns: [
"**/__tests__/**",
"**.test.**",
".eslintrc.js",
"scripts/",
"node_modules",
"dist",
"build",
"__mocks__",
"coverage",
"packages/**/lib",
"**/__e2e__/**",
'**/__tests__/**',
'**.test.**',
'.eslintrc.js',
'scripts/',
'node_modules',
'dist',
'build',
'__mocks__',
'coverage',
'packages/**/lib',
'**/__e2e__/**',

// Forked package
"amplify-velocity-template",
'amplify-velocity-template',

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

// Ignore project/file templates
"function-template-dir",
"/packages/graphql-predictions-transformer/lambdaFunction",
'function-template-dir',
'/packages/graphql-predictions-transformer/lambdaFunction',

// Ignore override resource test files
"/packages/amplify-e2e-tests/overrides",
'/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-e2e-tests/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",
"/packages/amplify-category-notifications/lib",
"/amplify-category-interactions/lib",
"/packages/amplify-category-custom/src/utils/generate-cfn-from-cdk.ts",
"/packages/amplify-environment-parameters/lib",
"/packages/amplify-opensearch-simulator/lib",
'/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-e2e-tests/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',
'/packages/amplify-category-notifications/lib',
'/amplify-category-interactions/lib',
'/packages/amplify-category-custom/src/utils/generate-cfn-from-cdk.ts',
'/packages/amplify-environment-parameters/lib',
'/packages/amplify-opensearch-simulator/lib',

// Ignore CHANGELOG.md files
"/packages/*/CHANGELOG.md",
],
'/packages/*/CHANGELOG.md',
// Ignore autogenerated API files
'/packages/*/API.md'
]
};
5 changes: 1 addition & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"jest.showCoverageOnLoad": true,
"jest.runAllTestsFirst": false,
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"copyfiles": "^2.2.0",
"eslint": "^7.19.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^26.1.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/amplify-opensearch-simulator/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
```ts

/// <reference types="node" />

import { $TSAny } from 'amplify-cli-core';
import execa from 'execa';
import { GetPackageAssetPaths } from 'amplify-cli-core';
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13521,6 +13521,11 @@ eslint-config-airbnb@^18.0.1:
object.assign "^4.1.2"
object.entries "^1.1.2"

eslint-config-prettier@^8.5.0:
version "8.5.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz#5a81680ec934beca02c7b1a61cf8ca34b66feab1"
integrity sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==

eslint-config-react-app@^7.0.0:
version "7.0.1"
resolved "https://registry.npmjs.org/eslint-config-react-app/-/eslint-config-react-app-7.0.1.tgz#73ba3929978001c5c86274c017ea57eb5fa644b4"
Expand Down

0 comments on commit 6ab3253

Please sign in to comment.