RuboCop on diff for Ruby files + ES6 syntax checker for JavaScript files + ERB template support: lint only what's new/changed
group :development, :test
gem 'ccru', require: false
end# Commit your code
git add some_files
git commit -m "commit message"
# Check changed Ruby, JavaScript, and ERB files in git diff (compared to merge-base)
bundle exec ccru
# Check specific files (No need commit)
bundle exec ccru path/to/file.rb path/to/script.js path/to/template.erb# Set default base branch for git diff comparison
export CCRU_BASE=develop
bundle exec ccru- Ruby files:
.rb- Checked with RuboCop - JavaScript files:
.js- Checked for ES6 syntax violations + code quality - ERB templates:
.erb- Checked with custom ERB linter for conventions
- Automatically checks ERB conventions and formatting
- Validates proper spacing:
<% code %>instead of<%code%> - Checks comment format:
<%# comment %>instead of<% # comment %> - Ensures proper output spacing:
<%= code %>instead of<%=code%> - Maps violations back to original ERB line numbers
The following ES6+ syntax patterns are detected and flagged as errors:
- Arrow functions:
=>syntax - const/let:
constandletdeclarations - Template literals:
`string ${variable}` - Destructuring:
{ prop } = objassignments - Spread operator:
...syntax - ES6 classes:
classdeclarations - ES6 modules:
import/exportstatements - Default parameters:
function(param = value) - Rest parameters:
function(...args)
- Trailing whitespace: Detects spaces at end of lines
- Missing final newline: Ensures files end with newline
- Line length: Maximum line length checking (120 characters)
- Console statements: Warns about
console.log,console.debug, etc. - Eval usage: Errors on dangerous
eval()calls - With statement: Errors on deprecated
withstatements - Document write: Warns about
document.write()usage
- Loose equality: Warns about
==vs===usage (allows== nulland== undefined) - Loose inequality: Warns about
!=vs!==usage - Unused variables: Detects potentially unused variable declarations
- Missing semicolons: Identifies missing semicolons (with smart detection)
- Inline comments: Warns about inline comments at end of code lines
- innerHTML usage: Warns about potential XSS vulnerabilities
- Global variables: Warns about global scope pollution
This project is licensed under the MIT License.