Skip to content

Commit

Permalink
feat(rule-set): Add member access as well as function name (#4)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This adds `member-access` as a required rule.
This rule forces the user to add `public`, `private` and `protected` modifiers
to their class members. To migrate, install the new version and use the
given visibility members on classes.
  • Loading branch information
buehler authored and mfeltscher committed Mar 26, 2018
1 parent 7f09d0c commit 626d1b0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ developers, but can become relevant if `x` can be `true | false | null`.
*This rule only works if [Type Information / Checking is available](https://palantir.github.io/tslint/rules/no-boolean-literal-compare/).*

### No Strict Boolean Expressions

With `strict-boolean-expressions` only boolean values can be used with `!`, `&&`, `||`, ternary operators, if conditions and loops.
JavaScript allows quite a few neat shorthand expressions with non-boolean value, which we don't want to prohibit.

*This rule only works if [Type Information / Checking is available](https://palantir.github.io/tslint/rules/no-boolean-literal-compare/).*

### Member Access

Force the user to add `public`, `protected` and `private` information to the
members of a class. This leads to better readability (despite the default
of `public`).

## Usage

Install using NPM:
Expand Down Expand Up @@ -95,5 +102,16 @@ like Code Reviews, to prevent an increase in unreadable code.
Sometimes filenames are not very meaningful and developers should be allowed to change default import statements, as they have the
same possibility with aliases for named imports (`import { Foo as Bar } from 'foo';`).

### JSX No Lambda

Since there are very little performance impacts on lambda expressions in jsx,
we decided to allow lambdas in jsx props.

### Function Name

If you use default exports, you can name your exported function with a capital
letter. This leads to a better understanding of several IDE tools.
`export default function Link() ...`

## Release notes
The release notes can be found in the [release section](https://github.com/smartive/tslint-config/releases).
13 changes: 12 additions & 1 deletion tslint-react.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
],
"jsx-boolean-value": ["never"],
"jsx-no-multiline-js": false,
"import-name": false
"jsx-no-lambda": false,
"import-name": false,
"function-name": [
true,
{
"function-regex": "/^([a-z$]|[A-Z$][a-z\\d])[\\w\\d]+$/",
"method-regex": "/^[a-z$][\\w\\d]+$/",
"private-method-regex": "/^[a-z$][\\w\\d]+$/",
"protected-method-regex": "/^[a-z$][\\w\\d]+$/",
"static-method-regex": "/^[a-z$][\\w\\d]+$/"
}
]
}
}
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"allow-leading-underscore"
],
"no-boolean-literal-compare": false,
"strict-boolean-expressions": false
"strict-boolean-expressions": false,
"member-access": true
}
}

0 comments on commit 626d1b0

Please sign in to comment.