-
Notifications
You must be signed in to change notification settings - Fork 943
eslint rules for firebase projects #1831
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,159 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"@typescript-eslint/tslint" | ||
], | ||
"parserOptions": { | ||
"ecmaVersion": 2015, | ||
"sourceType": "module" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*test.ts", | ||
"**/test/**/*.ts" | ||
], | ||
"rules": { | ||
"no-unused-expressions": "off" | ||
} | ||
} | ||
], | ||
"rules": { | ||
"curly": [ | ||
"error", | ||
"all" | ||
], | ||
"guard-for-in": "error", | ||
"no-extra-label": "error", | ||
"no-unused-labels": "error", | ||
"new-parens": "error", | ||
"no-new-wrappers": "error", | ||
"no-debugger": "error", | ||
"no-duplicate-case": "error", | ||
"no-throw-literal": "error", | ||
"no-return-await": "error", | ||
"no-unsafe-finally": "error", | ||
"no-unused-expressions": [ | ||
"error", | ||
{ | ||
"allowShortCircuit": true | ||
} | ||
], | ||
"no-var": "error", | ||
"object-shorthand": "error", | ||
"prefer-arrow-callback": [ | ||
"error", | ||
{ | ||
"allowNamedFunctions": true | ||
} | ||
], | ||
"prefer-const": [ | ||
"error", | ||
{ | ||
"destructuring": "all" | ||
} | ||
], | ||
"radix": "error", | ||
"default-case": "error", | ||
"eqeqeq": [ | ||
"error", | ||
"always", | ||
{ | ||
"null": "ignore" | ||
} | ||
], | ||
"no-caller": "error", | ||
"no-cond-assign": ["error", "always"], | ||
"use-isnan": "error", | ||
"camelcase": "error", | ||
"id-blacklist": [ | ||
"error", | ||
"any", | ||
"number", | ||
"string", | ||
"boolean" | ||
], | ||
"@typescript-eslint/array-type": [ | ||
"error", | ||
"array-simple" | ||
], | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
"types": { | ||
"Object": "Use object instead.", | ||
"String": "Use 'string' instead.", | ||
"Number": "Use 'number' instead.", | ||
"Boolean": "Use 'boolean' instead." | ||
} | ||
} | ||
], | ||
"@typescript-eslint/class-name-casing": "error", | ||
"@typescript-eslint/interface-name-prefix": [ | ||
"error", | ||
"never" | ||
], | ||
"@typescript-eslint/prefer-interface": "error", | ||
"@typescript-eslint/explicit-member-accessibility": [ | ||
"error", | ||
{ | ||
"accessibility": "no-public", | ||
"overrides": { | ||
"parameterProperties": "explicit" | ||
} | ||
} | ||
], | ||
"@typescript-eslint/no-angle-bracket-type-assertion": "error", | ||
"@typescript-eslint/no-explicit-any": "error", | ||
"@typescript-eslint/no-namespace": [ | ||
"error", | ||
{ | ||
"allowDeclarations": true | ||
} | ||
], | ||
"@typescript-eslint/no-triple-slash-reference": "error", | ||
"@typescript-eslint/no-require-imports": "error", | ||
"@typescript-eslint/no-useless-constructor": "error", | ||
"@typescript-eslint/semi": "error", | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"error", | ||
{ | ||
"allowExpressions": true | ||
} | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"varsIgnorePattern": "^_", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"@typescript-eslint/tslint/config": [ | ||
"error", | ||
{ | ||
"rules": { | ||
"ban": [true, | ||
{"name": ["it", "skip"]}, | ||
{"name": ["it", "only"]}, | ||
{"name": ["describe", "skip"]}, | ||
{"name": ["describe", "only"]}, | ||
{"name": ["xit"]}, | ||
{"name": ["xdescribe"]}, | ||
{"name": "parseInt", "message": "tsstyle#type-coercion"}, | ||
{"name": "parseFloat", "message": "tsstyle#type-coercion"}, | ||
{"name": "Array", "message": "tsstyle#array-constructor"} | ||
], | ||
"jsdoc-format": true, | ||
"no-floating-promises": true, | ||
"arrow-return-shorthand": true | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains hidden or 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,6 @@ | ||
{ | ||
"extends": "../../config/.eslintrc.json", | ||
"parserOptions": { | ||
"project": "tsconfig.json" | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,6 @@ | ||
{ | ||
"extends": "../../config/.eslintrc.json", | ||
"parserOptions": { | ||
"project": "tsconfig.json" | ||
} | ||
} |
This file contains hidden or 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.
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.
FWIW- Looking through the Firestore errors, this is the other rule we run into a lot. Our current tslint rules prevent unused variables but allow unused arguments, and we have a lot of violations (~170 though some of those are for
_
, see below), and the ones I've looked at are mostly intentional... Basically there are many places where a function is implementing some contract and we want the function signature to convey the contract, even if the function implementation doesn't need everything provided by the contract.As a simple example:
Here, It so happens that
doc
isn't needed, but the iterate function will be passed 'key' and 'doc', and it would be confusing to make it look like it's not!We also have various interfaces with multiple implementations, and not all implementations need all the function arguments provided... but it's still worth explicitly conforming to the contract.
We could suppress all of these, but I wouldn't be excited about adding that kind of clutter... So I would suggest that we make the ignore pattern be something like
"^_"
and then change all of the intentionally unused parameters to just be prefixed with an underscore, e.g. "_doc" above. That way we can keep the rule, but cleanly mark all the intentional ones without it being too awkward.WDYT?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes! That's the intention, but I made a mistake in the regex (I meant to have
^_.*$
). Update the regex to "^_".