├── README.md ├── configs ├── .overcommit.yml ├── .rubocop.yml ├── .scss-lint.yml └── .slim-lint.yml └── rubocop.gif /README.md: -------------------------------------------------------------------------------- 1 | # Linters configuration 2 | ![](rubocop.gif) 3 | ## Why we use linters? 4 | Lint is a tool that analyzes source code to flag programming errors, bugs, stylistic errors, and suspicious constructs. So we don't need to spend time for code syntax checking, linters can do it for us. 5 | ## Linters libraries 6 | * [Rubocop](https://github.com/rubocop-hq/rubocop) 7 | * [ES-lint](https://github.com/eslint/eslint) 8 | * [SCSS-lint](https://github.com/brigade/scss-lint) 9 | * [Slim-lint](https://github.com/sds/slim-lint) 10 | * [Overcommit](https://github.com/brigade/overcommit) 11 | ## Rubocop 12 | [Rubocop](https://github.com/rubocop-hq/rubocop) is a Ruby static code analyzer and formatter, based on the Ruby community style guide. 13 | 14 | RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options. 15 | ### Installation 16 | 17 | ```sh 18 | gem install rubocop 19 | ``` 20 | If you'd rather install RuboCop using bundler, don't require it in your Gemfile: 21 | ```ruby 22 | gem 'rubocop', require: false 23 | ``` 24 | [Rubocop config example](configs/.rubocop.yml) 25 | ## Es Lint 26 | [ES-lint](https://github.com/eslint/eslint) is a fully pluggable tool for identifying and reporting on patterns in JavaScript 27 | ### Installation 28 | If you want to include ESLint as part of your project's build system, we recommend installing it locally. You can do so using npm: 29 | ```sh 30 | npm install eslint --save-dev 31 | ``` 32 | You should then set up a configuration file: 33 | ```sh 34 | $ ./node_modules/.bin/eslint --init 35 | ``` 36 | After that, you can run ESLint on any file or directory like this: 37 | ```sh 38 | ./node_modules/.bin/eslint yourfile.js 39 | ``` 40 | ## SCSS-lint 41 | [SCSS-lint](https://github.com/brigade/scss-lint) is a configurable tool for writing clean and consistent SCSS 42 | ### Installation 43 | Add to your Gemfile: 44 | ```ruby 45 | gem 'scss_lint' 46 | ``` 47 | After that, you can run SCSS-lint on any file or directory like this: 48 | ```sh 49 | scss-lint app/assets/stylesheets/ 50 | ``` 51 | or 52 | ```sh 53 | scss-lint app/assets/stylesheets/**/*.css.scss 54 | ``` 55 | [SCSS-lint config example](configs/.scss-lint.yml) 56 | 57 | ## Slim-lint 58 | [Slim-lint](https://github.com/sds/slim-lint) is a configurable tool for analyzing Slim templates 59 | ### Installation 60 | Add to your Gemfile: 61 | ```ruby 62 | gem 'slim_lint' 63 | ``` 64 | Run slim-lint from the command line by passing in a directory (or multiple directories) to recursively scan: 65 | ```sh 66 | slim-lint app/views/ 67 | ``` 68 | [Slim-lint config example](configs/.slim-lint.yml) 69 | 70 | ## Overcommit 71 | [Overcommit](https://github.com/brigade/overcommit) is a fully configurable and extendable Git hook manager. 72 | 73 | ### Installation 74 | Overcommit is installed via RubyGems. It is strongly recommended that your environment supports running gem install without requiring sudo privileges. Using a Ruby version manager like rbenv or rvm can help here. 75 | ```sh 76 | gem install overcommit 77 | ``` 78 | You can then run the overcommit command to install hooks into repositories. 79 | ```sh 80 | mkdir important-project 81 | cd important-project 82 | git init 83 | overcommit --install 84 | ``` 85 | [Overcommit config example](configs/.overcommit.yml) 86 | ## License 87 | Copyright © 2015-2019 Codica. It is released under the [MIT License](https://opensource.org/licenses/MIT). 88 | 89 | ## About Codica 90 | 91 | [![Codica logo](https://www.codica.com/assets/images/logo/logo.svg)](https://www.codica.com) 92 | 93 | We love open source software! See [our other projects](https://github.com/codica2) or [hire us](https://www.codica.com/) to design, develop, and grow your product. 94 | -------------------------------------------------------------------------------- /configs/.overcommit.yml: -------------------------------------------------------------------------------- 1 | PreCommit: 2 | ALL: 3 | problem_on_unmodified_line: ignore 4 | required: false 5 | quiet: false 6 | RuboCop: 7 | enabled: true 8 | on_warn: fail # Treat all warnings as failures 9 | SlimLinter: 10 | enabled: true 11 | command: ['slim-lint', 'app/views/'] 12 | ScssLint: 13 | enabled: true 14 | required: true 15 | command: ['bundle', 'exec', 'scss-lint'] 16 | on_warn: fail 17 | EsLint: 18 | required_executable: 'npm' 19 | enabled: true 20 | required: true 21 | command: ['./node_modules/.bin/eslint'] 22 | on_warn: fail -------------------------------------------------------------------------------- /configs/.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_from: .rubocop_todo.yml 2 | AllCops: 3 | TargetRubyVersion: 2.5.1 4 | Exclude: 5 | - 'db/**/*' 6 | - 'bin/*' 7 | - 'config/**/*' 8 | - 'public/**/*' 9 | - 'spec/**/*' 10 | - 'test/**/*' 11 | - 'vendor/**/*' 12 | - 'spec/fixtures/**/*' 13 | - 'tmp/**/*' 14 | - 'node_modules/**/*' 15 | Style/FrozenStringLiteralComment: 16 | Enabled: false 17 | 18 | Style/Documentation: 19 | Enabled: false 20 | 21 | Style/ClassAndModuleChildren: 22 | Enabled: false 23 | 24 | Layout/EmptyLinesAroundModuleBody: 25 | EnforcedStyle: empty_lines 26 | 27 | Layout/EmptyLinesAroundClassBody: 28 | EnforcedStyle: empty_lines 29 | 30 | Metrics/LineLength: 31 | Max: 200 32 | 33 | Metrics/ClassLength: 34 | Max: 350 35 | 36 | Metrics/ModuleLength: 37 | Max: 350 38 | 39 | Metrics/AbcSize: 40 | Max: 35 41 | 42 | Metrics/MethodLength: 43 | Max: 25 44 | 45 | Metrics/CyclomaticComplexity: 46 | Max: 7 47 | 48 | Rails: 49 | Enabled: true 50 | 51 | Rails/InverseOf: 52 | Enabled: false -------------------------------------------------------------------------------- /configs/.scss-lint.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | ColorVariable: 3 | enabled: false 4 | NestingDepth: 5 | enabled: false 6 | PseudoElement: 7 | enabled: false 8 | SelectorDepth: 9 | enabled: false 10 | ImportantRule: 11 | enabled: false 12 | QualifyingElement: 13 | enabled: false 14 | VendorPrefix: 15 | enabled: false 16 | -------------------------------------------------------------------------------- /configs/.slim-lint.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | LineLength: 3 | enabled: true 4 | max: 150 -------------------------------------------------------------------------------- /rubocop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codica2/clean-code-tools/48605a03c0a665581b5c2c61eaaf67476f7fe9d0/rubocop.gif --------------------------------------------------------------------------------