Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

coffeelint

clutchski131kMIT2.1.0

Lint your CoffeeScript

lint, coffeescript, coffee-script

readme

CoffeeLint

CoffeeLint is a style checker that helps keep CoffeeScript code clean and consistent.

For guides on installing, using and configuring CoffeeLint, head over here.

To suggest a feature, report a bug, or general discussion, head over here.

Team

Current:

Past:

Contributing

  • New rules should be set to a warn level. Developers will expect new changes to NOT break their existing workflow, so unless your change is extremely usefull, default to warn. Expect discussion if you choose to use error.

  • Look at existing rules and test structures when deciding how to name your rule. no_foo.coffee is used for many tests designed to catch specific errors, whereas foo.coffee is used for tests that are designed to enforce formatting and syntax.

Steps

  1. Fork the repo locally.
  2. Run npm install to get dependencies.
  3. Create your rule in a single file as src/rules/your_rule_here.coffee, using the existing rules as a guide. You may examine the AST and tokens using http://asaayers.github.io/clfiddle/.
  4. Add your test file my_test.coffee to the test directory.
  5. Register your rule in src/coffeelint.coffee.
  6. Run your test using npm run testrule test/your_test_here.coffee.
  7. Run the whole tests suite using npm test.
  8. Check that your rule's documentation is generated properly (see Updating documentation when adding a new rule below).
  9. Squash all commits into a single commit when done.
  10. Submit a pull request.

Build Status

Updating documentation when adding a new rule

When adding a new rule, its documentation is specified by setting a description property within its rule property:

module.exports = class NoComment

    rule:
        name: 'no_comment'
        level: 'ignore'
        message: 'No comment'
        description: '''
            Disallows any comment in the code
            '''

    tokens: ['#', '###']

    lintToken : (token, tokenApi) ->
        return {context: "Found '#{token[0]}'"}

The description property is a string that can embed HTML code:

description: '''
    Disallows any comment in the code. This code would not pass:
    <pre>
    <code>### Some code with comments
    foo = ->
        # some other comments
        bar()
    </code>
    </pre>
    '''

Coffeelint's website generates each rule's documentation based on this description property.

When adding a new rule, it is suggested that you check that the documentation for your new rule is generated correctly. In order to do that, you should follow these steps:

  • Checkout the branch that contains the changes adding the new rule.
  • Run npm run compile.
  • Checkout the gh-pages branch: git checkout origin/gh-pages.
  • Run cp lib/coffeelint.js js/coffeelint.js.
  • Regenerate the HTML documentation: rake updatehtml. Note that you will probably need to install rake.
  • Open the index.html file with your favorite browser and make sure that your rule's documentation is generated properly.

changelog

Release Steps

  1. Review changelog

I always use the top changelog link on coffeelint.org and change it to point to compare/vx.x.x...master. Look through the pull request to figure out whether this is a minor or patch release.

  1. Tag

CoffeeLint follows semver. When a new rule is added even if it's off by default, it's at least a minor release. There are some things marked deprecated. If we ever have a need for a 2.0 I'll remove those at that time.

npm version <major|minor|patch>
  1. Write changelog

git checkout gh-pages

The changelog is in index-bottom.html. Update it based on the PRs found in step 1. I don't always mention every PR. Many internal changes like updates to Travis don't matter to users of CoffeeLint, so I leave them out.

This next step is going to end up checkout out master, so I'll usually commit the changelog updates and then I'll run git commit --amend after the next step.

  1. Update gh-page's coffeelint

rake update

I've never rewritten how this gets generated. Because it needs to pull a compiled version of CoffeeLint from master, rake update gives you a set of commands to copy and paste.

# It doesn't matter if you ammend or add a new commit, this is just what I do.
git commit --amend
  1. Release all the things!

git checkout master
git push origin master
git push origin gh-pages
git push origin <tag>

I think it's important that people be able to install CoffeeLint directly from git. People also got upset when the NPM version required installing browserify and coffeeify when they were never actually used. For this reason I have a prepublish script that will yank those and the install script out of package.json. I had this fail to run for me once, so now I run it manually just to make sure it's fine before I publish.

npm run prepublish
git diff
npm publish
git checkout package.json