-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(repo): migrate to eslint #12620
Closed
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
fba396e
chore(repo): use typescript 5.0.2 across workspace
HuiSF 2dc051f
chore(repo): unify tsconfig set up across packages
HuiSF 9ab97c0
chore(repo): migrate to eslint
HuiSF 3798c1d
chore(repo): update jest setup script to work with eslint and tsconfig
HuiSF a3d1e90
chore(adapter-nextjs): run eslint src --fix
HuiSF d2d35d4
chore(analytics): run eslint --fix
HuiSF 6e1eeca
chore(api): run eslint --fix
HuiSF b7b39c4
chore(api-rest): run eslint --fix
HuiSF 700a88d
chore(aws-amplify): run eslint --fix
HuiSF 6607c26
chore(core): run eslint --fix
HuiSF 225b71f
chore(storage): run eslint --fix
HuiSF 246e476
chore(rtn-web-browser): run eslint --fix
HuiSF fc0de6d
chore(rtn-push-notification): run eslint --fix
HuiSF ee46b65
chore(react-native): run eslint --fix
HuiSF 606ce07
chore(pubsub): run eslint --fix
HuiSF f7f249f
chore(auth): run eslint --fix
HuiSF bbb63d9
chore(predictions): run eslint --fix
HuiSF 4d099ac
chore(notifications): run eslint --fix
HuiSF 8f453d3
chore(geo): run eslint --fix
HuiSF 361d7e1
chore(datastore-adapter): run eslint --fix
HuiSF f143c5e
chore(api-graphql): run eslint --fix
HuiSF 03ab192
chore(interactions): run eslint --fix
HuiSF 4f59ef1
chore(datastore): run eslint --fix
HuiSF 52a1802
fix(repo): using js-yaml load function instead of safeLoad
HuiSF 54a4dd4
chore(repo): remove unused husky config
HuiSF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/** @type {import("eslint").ESLint.ConfigData}*/ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'standard', | ||
'plugin:import/errors', | ||
'plugin:import/recommended', | ||
'plugin:import/typescript', | ||
'plugin:@typescript-eslint/stylistic', | ||
'plugin:@typescript-eslint/recommended', | ||
'prettier', | ||
], | ||
plugins: [ | ||
'@stylistic', | ||
'@typescript-eslint', | ||
'no-relative-import-paths', | ||
'unused-imports', | ||
'import', | ||
'jsdoc', | ||
], | ||
env: { | ||
es6: true, | ||
node: true, | ||
}, | ||
ignorePatterns: [ | ||
'dist', | ||
'node_modules', | ||
'.eslintrc.*', | ||
'rollup', | ||
'rollup.config.*', | ||
'setupTests.ts', | ||
'jest.setup.*', | ||
'jest.config.*', | ||
// temporarily disable lint on __tests__ | ||
'__tests__', | ||
], | ||
rules: { | ||
camelcase: [ | ||
'error', | ||
{ | ||
allow: [ | ||
'graphql_headers', | ||
// exceptions for the legacy config | ||
/^(aws_|amazon_)/, | ||
'access_key', | ||
'secret_key', | ||
'session_token', | ||
// exceptions for the auth package | ||
'redirect_uri', | ||
'response_type', | ||
'client_id', | ||
'identity_provider', | ||
'code_challenge', | ||
'code_challenge_method', | ||
'grant_type', | ||
'code_verifier', | ||
'logout_uri', | ||
'id_token', | ||
'access_token', | ||
'token_type', | ||
'expires_in', | ||
'error_description', | ||
// exceptions for the notifications package | ||
'campaign_id', | ||
'delivery_type', | ||
'treatment_id', | ||
'campaign_activity_id', | ||
], | ||
}, | ||
], | ||
'import/no-deprecated': 'warn', | ||
'import/no-empty-named-blocks': 'error', | ||
'import/no-mutable-exports': 'error', | ||
'import/no-relative-packages': 'error', | ||
'import/newline-after-import': 'error', | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [ | ||
'builtin', | ||
['external', 'internal', 'parent'], | ||
'sibling', | ||
'index', | ||
'object', | ||
'type', | ||
], | ||
'newlines-between': 'always', | ||
pathGroups: [ | ||
{ | ||
pattern: '~/**', | ||
group: 'parent', | ||
}, | ||
], | ||
}, | ||
], | ||
'no-eval': 'error', | ||
'no-param-reassign': 'error', | ||
'no-shadow': 'off', | ||
'no-use-before-define': 'off', | ||
'no-useless-constructor': 'off', | ||
'no-trailing-spaces': 'error', | ||
'no-return-await': 'error', | ||
'object-shorthand': 'error', | ||
'prefer-destructuring': 'off', | ||
'promise/catch-or-return': [ | ||
'error', | ||
{ terminationMethod: ['then', 'catch', 'asCallback', 'finally'] }, | ||
], | ||
'space-before-function-paren': 'off', | ||
'sort-imports': ['error', { ignoreDeclarationSort: true }], | ||
'unused-imports/no-unused-imports': 'error', | ||
'unused-imports/no-unused-vars': [ | ||
'error', | ||
{ | ||
vars: 'all', | ||
varsIgnorePattern: '^_', | ||
args: 'after-used', | ||
argsIgnorePattern: '^_', | ||
}, | ||
], | ||
'valid-typeof': ['error', { requireStringLiterals: false }], | ||
'@stylistic/comma-dangle': [ | ||
'error', | ||
{ | ||
arrays: 'always-multiline', | ||
objects: 'always-multiline', | ||
imports: 'always-multiline', | ||
exports: 'always-multiline', | ||
functions: 'always-multiline', | ||
enums: 'always-multiline', | ||
generics: 'always-multiline', | ||
tuples: 'always-multiline', | ||
}, | ||
], | ||
'@stylistic/function-call-argument-newline': ['error', 'consistent'], | ||
'@stylistic/indent': 'off', | ||
'@stylistic/max-len': [ | ||
'error', | ||
{ | ||
code: 120, | ||
ignoreComments: true, | ||
ignoreUrls: true, | ||
ignoreStrings: true, | ||
ignoreTemplateLiterals: true, | ||
ignoreRegExpLiterals: true, | ||
}, | ||
], | ||
'@stylistic/padding-line-between-statements': [ | ||
'error', | ||
{ blankLine: 'always', prev: '*', next: 'return' }, | ||
], | ||
'@typescript-eslint/method-signature-style': ['error', 'method'], | ||
'@typescript-eslint/no-confusing-void-expression': 'error', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }], | ||
'@typescript-eslint/no-shadow': 'error', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-use-before-define': [ | ||
'error', | ||
{ functions: false, variables: false, classes: false }, | ||
], | ||
'@typescript-eslint/no-useless-constructor': 'error', | ||
'@typescript-eslint/prefer-destructuring': [ | ||
'error', | ||
{ object: true, array: false }, | ||
], | ||
'@typescript-eslint/space-before-function-paren': [ | ||
'error', | ||
{ | ||
anonymous: 'never', | ||
named: 'never', | ||
asyncArrow: 'always', | ||
}, | ||
], | ||
'jsdoc/no-undefined-types': 1, | ||
}, | ||
settings: { | ||
'import/parsers': { | ||
'@typescript-eslint/parser': ['.ts', '.tsx'], | ||
}, | ||
'import/resolver': { | ||
typescript: { | ||
alwaysTryTypes: true, | ||
project: ['packages/*/tsconfig.json', 'tsconfig.json'], | ||
}, | ||
}, | ||
'import/ignore': ['react-native'], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This eslintrc is used when running `eslint src` (yarn lint) in the scope of each package in the lerna workspace | ||
// so that the no-relative-import-paths plugin can correctly apply rule checks | ||
|
||
/** @type {import("eslint").ESLint.ConfigData}*/ | ||
module.exports = { | ||
extends: '.eslintrc.js', | ||
rules: { | ||
'no-relative-import-paths/no-relative-import-paths': [ | ||
'error', | ||
{ | ||
allowSameFolder: true, | ||
prefix: '~', | ||
// relative to the root of a package itself | ||
rootDir: '.', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ docs | |
package.json | ||
yarn.lock | ||
package-lock.json | ||
.eslintrc.js | ||
www | ||
.stencil | ||
PULL_REQUEST_TEMPLATE.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
// List of extensions which should be recommended for users of this workspace. | ||
"recommendations": [ | ||
"esbenp.prettier-vscode", | ||
"tombonnike.vscode-status-bar-format-toggle" | ||
"dbaeumer.vscode-eslint", | ||
"streetsidesoftware.code-spell-checker" | ||
], | ||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||
"unwantedRecommendations": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
{ | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.detectIndentation": false, | ||
"editor.formatOnSave": true, | ||
"editor.insertSpaces": false, | ||
"editor.tabSize": 4, | ||
"prettier.requireConfig": true, | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll.eslint": true | ||
}, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.detectIndentation": false, | ||
"editor.formatOnSave": true, | ||
"editor.insertSpaces": false, | ||
"editor.tabSize": 4, | ||
"prettier.requireConfig": true, | ||
"typescript.preferences.importModuleSpecifier": "non-relative", | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import typescript from 'typescript'; | ||
import * as tsJest from 'ts-jest'; | ||
import deepmerge from 'deepmerge'; | ||
|
||
/** | ||
* Creates a jest config object by merging typescript compiler options and jest config object into the base jest config. | ||
* | ||
* @param {typescript.CompilerOptions} tsCompilerOptions The compiler options of `tsconfig`. | ||
* @param {tsJest.JestConfigWithTsJest?} jestConfig The jest config to be merged into the base jest config. | ||
* @return {tsJest.JestConfigWithTsJest} The jest config object. | ||
*/ | ||
export const getJestConfig = (tsCompilerOptions, jestConfig = {}) => | ||
deepmerge( | ||
{ | ||
workerIdleMemoryLimit: '512MB', | ||
coveragePathIgnorePatterns: ['/node_modules/', 'dist', '__tests__'], | ||
setupFiles: ['../../jest.setup.js'], | ||
testEnvironment: 'jsdom', | ||
testRegex: '/__tests__/.*\\.(test|spec)\\.[jt]sx?$', | ||
transform: { | ||
'^.+\\.(js|jsx|ts|tsx)$': [ | ||
'ts-jest', | ||
{ | ||
tsconfig: 'tsconfig.test.json', | ||
}, | ||
], | ||
}, | ||
moduleNameMapper: tsJest.pathsToModuleNameMapper( | ||
tsCompilerOptions.paths, | ||
{ | ||
prefix: '<rootDir>/', | ||
}, | ||
), | ||
}, | ||
jestConfig, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createRequire } from 'module'; | ||
|
||
const require = createRequire(import.meta.url); | ||
|
||
/** | ||
* Resolves module path name. | ||
* | ||
* @param {String} moduleName Module name. | ||
* @returns {String} Module path name; | ||
*/ | ||
export const requireResolve = moduleName => require.resolve(moduleName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to use space in ALL places instead of tabs one day🙏