Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TSLint rules for enforcing Clean Code

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license.txt
NotificationsYou must be signed in to change notification settings

Glavin001/tslint-clean-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A set ofTSLint rules used to enforceClean Code practices. Inspired byClean Code: A Handbook of Agile Software Craftsmanship.

👉 Sign up forCodePass,the Quickest Way To Solve Your Coding Errors! 💥

Installation

npm install tslint-clean-code

Configuration

Configuretslint.json

In yourtslint.json file, extend this package.For example:

{"extends": ["tslint-clean-code"  ],"rules": {"newspaper-order":true  }}

You can also extend other tslint config packages to combine this plugin with other community custom rules.

Configure your Grunt build task

Add the new rulesDirectory to your tslint task:

grunt.initConfig({  tslint: {    options: {      rulesDirectory: 'node_modules/tslint-clean-code/dist/src',      configuration: grunt.file.readJSON("tslint.json")    },    files: {      src: ['src/file1.ts', 'src/file2.ts']    }  }})

The tslint.json file does not change format when using this package. Just add our rule definitions to your existing tslint.json file.

Supported Rules

Rule NameDescriptionSince
id-lengthEnforces a minimum and/or maximum identifier length convention.0.1.0
try-catch-firstTry-catch blocks must be first within the scope. Try-catch blocks are transactions and should leave your program in a consistent state, no matter what happens in the try.0.1.0
max-func-argsLimit the number of input arguments for a function. The ideal number of arguments for a function is zero (niladic).0.1.0
min-class-cohesionThe more variables a method manipulates the more cohesive that method is to its class. A class in which each variable is used by each method is maximally cohesive. We would like cohesion to be high. When cohesion is high, it means that the methods and variables of the class are co-dependent and hang together as a logical whole.0.1.0
newspaper-orderWe would like a source file to be like a newspaper article. Detail should increase as we move downward, until at the end we find the lowest level functions and details in the source file.0.1.0
no-flag-argsFunctions should only do one thing, therefore passing a boolean into a function is a bad practice. The function does one thing if the flag is true and another if the flag is false!0.1.0
no-for-each-pushEnforce usingArray.prototype.map instead ofArray.prototype.forEach andArray.prototype.push.0.1.0
no-feature-envyA method accesses the data of another object more than its own data.0.1.8
no-map-without-usageEnsure results ofArray.prototype.map is either assigned to variable or returned0.1.0
no-complex-conditionalsEnforce the maximum complexity of conditional expressions.0.1.0
prefer-dry-conditionalsDon't-Repeat-Yourself in if statement conditionals, instead use Switch statements.0.1.0
no-commented-out-codeCode must not be commented out.0.2.0

Development

To develop tslint-clean-code simply clone the repository, install dependencies and run grunt:

git clone git@github.com:Glavin001/tslint-clean-code.git --config core.autocrlf=input --config core.eol=lfcd tslint-clean-codenpm installgrunt allgrunt create-rule --rule-name=no-something-or-other

Debug code

If command fails because of file access permissions, prefix it with sudo.

npm install -g node-inspector

Then run:

node-debug grunt mochaTest

Thenode-debug command will load Node Inspector in your default browser (works in Chrome and Opera only).

Set a breakpoint somewhere in your code and resume execution. Your breakpoint should be hit.

Thank you

Thank you to maintainers oftslint-microsoft-contrib, from which this repository was forked. The initial structure was kept and new rules were added, this would not have been possible without Microsoft's awesome work!

About

TSLint rules for enforcing Clean Code

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors6


[8]ページ先頭

©2009-2025 Movatter.jp