Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Add ability to ban global functions #1408

Merged
merged 55 commits into from
Sep 6, 2016
Merged

Add ability to ban global functions #1408

merged 55 commits into from
Sep 6, 2016

Conversation

soniro
Copy link
Contributor

@soniro soniro commented Jul 17, 2016

Fixes #327.

This is my suggested solution. Please see the discussion in the issue about the syntax of global bans.

@jkillian
Copy link
Contributor

jkillian commented Aug 9, 2016

Hi @soniro, thanks for the PR! Sorry for the delay in reviewing this. I'm happy with the syntax you proposed, just one question: would ["someFunc"] ban someObj.someFunc() or only the standalone version of it?

@@ -23,20 +23,18 @@ export class Rule extends Lint.Rules.AbstractRule {
/* tslint:disable:object-literal-sort-keys */
public static metadata: Lint.IRuleMetadata = {
ruleName: "ban",
description: "Bans the use of specific functions.",
descriptionDetails: "At this time, there is no way to disable global methods with this rule.",
description: "Bans the use of specific functions or global methods.",
optionsDescription: "A list of `['object', 'method']` pairs which ban `object.method()`.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's update this description as well?

@jkillian
Copy link
Contributor

jkillian commented Aug 9, 2016

This PR looks good by the way! Looks like you'll need to merge master into it before we can merge though

@adidahiya
Copy link
Contributor

ping @soniro?

@soniro
Copy link
Contributor Author

soniro commented Aug 26, 2016

Hey guys!

Sorry, for my delay, too. I'm very busy at the moment.
I'll send you an update with the description and a new testcase on Monday.

The global ban will not ban 'someObject,someFunction()', so it has no unexpected side effects.

adidahiya and others added 16 commits August 31, 2016 21:59
* Add linterOptions to tslint.json

- only enable type checking during tests when typeCheck: true is configured
- fixes palantir#1402

* Code style
* Add new Rule: arrow-parens

* Add test

* modify some documentations
* Core quote-props rule

* Tweaks for code review

* rename
…#1097 (palantir#1349)

* Implement rule to forbid return statements in finally blocks palantir#1097

* explore the try statement fully to pick up violations in nested scopes

* switch to a scope aware rule walker to reduce number of passes over the AST

* Add support for other control flow statements in finally blocks (break, continue, throws)

* improve the rationale description for the no unsafe finally rule

* rename rule to no-unsafe-finally to be inline with eslint

* add new rule to latest config

* pull out helper functions from the walker class.

* fix tslint violations (which didn't occur locally)
* task(formatter): added stylish formatter

* Support non-colors terminal in tests

* fix(stylish): lint quotes

* fix(stylish) 4 spaces indentation

* fix(stylish): correct strpad amount

* fix(stylish): test tuple position
* no-for-in-array rule

* Change array check

* Add typeCheck linterOption
…ges (palantir#1385)

* Updating ban rule to have better messages, and an optional explanation message as a 3rd parameter
This allows the code to compile correctly with TS 1.8.x and TS 2.x

See microsoft/TypeScript#9855 also
* Created IFix and IReplacement structures for representing fixes
  * programWalker includes createFix and createReplacement
* Added optional parameter to createFailure for suggesting fixes
* Modified semicolon rule to suggest fixes (add / remove semicolon)
* Modified testing to check against a file with fixes applied
  * If there is a ".ts.fix" file, then the test will take the first suggested fix and apply to the test file (without markup) and compare

Addresses palantir#561
jkillian and others added 20 commits August 31, 2016 22:03
* Remove docs/_site files that shouldn't be checked in

* gitignore files that shoudln't be checked in

* Don't tie site to a specific version of ruby

* Add note that type info is required for some rules
@soniro
Copy link
Contributor Author

soniro commented Aug 31, 2016

Sorry for the delay.
Finally I added the suggestions from the review and merged the master.

Please let me know if you have problems to merge my pull request.

@ChrisMBarr
Copy link
Contributor

Also related: #733

@jkillian jkillian merged commit 8db2e4f into palantir:master Sep 6, 2016
@jkillian
Copy link
Contributor

jkillian commented Sep 6, 2016

Thanks @soniro!

@ChrisMBarr
Copy link
Contributor

@soniro Does this still allow for custom ban messages like below?

["_", "each", "Don't rely on Underscore to perform loops. Use a 'for of' loop instead" ],

Would this allow for custom messages on the global function bans also?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.