diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2752eb9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +.DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4c229c3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 - First Release + +* Initial release diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..2dc0f03 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,5 @@ +Copyright (c) 2018, DopustimVladimir + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3fc73eb --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ + +# @dopustim/coffeelint-config + +Configuration file for CoffeeLint + +[![NPM](https://img.shields.io/npm/dt/@dopustim/coffeelint-config.svg?style=flat-square)](https://www.npmjs.com/package/@dopustim/coffeelint-config) + +[![GitHub tag](https://img.shields.io/github/tag/dopustim/coffeelint-config.svg?style=flat-square)](https://github.com/dopustim/coffeelint-config/tags) +[![GitHub stars](https://img.shields.io/github/stars/dopustim/coffeelint-config.svg?style=flat-square)](https://github.com/dopustim/coffeelint-config/stargazers) +[![GitHub issues](https://img.shields.io/github/issues/dopustim/coffeelint-config.svg?style=flat-square)](https://github.com/dopustim/coffeelint-config/issues) + +[![License](https://img.shields.io/badge/license-ISC-green.svg?style=flat-square)](/LICENSE.md) + +## Features + +- Provide Errors and Warnings +- 4 spaces for indentation (warning) +- 100 symbols per line (warning) +- Unix linebreaks (warning) + +## Usage + +Install `@dopustim/coffeelint-config` package via [NPM](https://www.npmjs.com/package/@dopustim/coffeelint-config): + +```sh +$ npm i -D coffeelint @dopustim/coffeelint-config +``` + +Extend this config in your `coffeelint.json`: + +```json +{ + "extends": "@dopustim/coffeelint-config" +} +``` + +Or use your `package.json`: + +```json +"coffeelintConfig": { + "extends": "@dopustim/coffeelint-config" +} +``` + +You can also reassign any rule for your needs: + +```json +{ + "extends": "@dopustim/coffeelint-config", + "rules": { + "space_operators": { + "level": "ignore" + } + } +} +``` + +## Rules + +You can find all rules on [official site](http://www.coffeelint.org/#options). + +## License + +[ISC License](./LICENSE.md) © 2018 Dopustim Vladimir diff --git a/package.json b/package.json new file mode 100644 index 0000000..3c4632b --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "@dopustim/coffeelint-config", + "version": "0.1.0", + "description": "Configuration file for CoffeeLint", + "keywords": [ + "configuration", + "config", + "json", + "validate", + "lint", + "linter", + "coffeelint" + ], + "author": "DopustimVladimir", + "license": "ISC", + "repository": "https://github.com/dopustim/coffeelint-config", + "main": "recommended.json", + "scripts": { + "test": "jasmine spec/index-spec.js" + }, + "devDependencies": { + "coffeelint": "^2.1.0", + "jasmine": "^3.3.0" + } +} diff --git a/recommended.json b/recommended.json new file mode 100644 index 0000000..7a9ee4a --- /dev/null +++ b/recommended.json @@ -0,0 +1,135 @@ +{ + "arrow_spacing": { + "level": "warn" + }, + "braces_spacing": { + "spaces": 0, + "empty_object_spaces": 0, + "level": "warn" + }, + "camel_case_classes": { + "level": "error" + }, + "coffeescript_error": { + "level": "error" + }, + "colon_assignment_spacing": { + "spacing": { + "left": 0, + "right": 1 + }, + "level": "warn" + }, + "cyclomatic_complexity": { + "value": 10, + "level": "warn" + }, + "duplicate_key": { + "level": "error" + }, + "empty_constructor_needs_parens": { + "level": "ignore" + }, + "ensure_comprehensions": { + "level": "warn" + }, + "eol_last": { + "level": "warn" + }, + "indentation": { + "value": 4, + "level": "warn" + }, + "line_endings": { + "value": "unix", + "level": "warn" + }, + "max_line_length": { + "value": 100, + "limitComments": true, + "level": "warn" + }, + "missing_fat_arrows": { + "is_strict": false, + "level": "ignore" + }, + "newlines_after_classes": { + "value": 3, + "level": "ignore" + }, + "no_backticks": { + "level": "error" + }, + "no_debugger": { + "console": false, + "level": "warn" + }, + "no_empty_functions": { + "level": "ignore" + }, + "no_empty_param_list": { + "level": "ignore" + }, + "no_implicit_braces": { + "strict": false, + "level": "ignore" + }, + "no_implicit_parens": { + "strict": false, + "level": "ignore" + }, + "no_interpolation_in_single_quotes": { + "level": "ignore" + }, + "no_nested_string_interpolation": { + "level": "warn" + }, + "no_plusplus": { + "level": "ignore" + }, + "no_private_function_fat_arrows": { + "level": "warn" + }, + "no_stand_alone_at": { + "level": "ignore" + }, + "no_tabs": { + "level": "error" + }, + "no_this": { + "level": "error" + }, + "no_throwing_strings": { + "level": "error" + }, + "no_trailing_semicolons": { + "level": "error" + }, + "no_trailing_whitespace": { + "allowed_in_comments": false, + "allowed_in_empty_lines": true, + "level": "error" + }, + "no_unnecessary_double_quotes": { + "level": "ignore" + }, + "no_unnecessary_fat_arrows": { + "level": "warn" + }, + "non_empty_constructor_needs_parens": { + "level": "ignore" + }, + "prefer_english_operator": { + "doubleNotLevel": "ignore", + "level": "warn" + }, + "space_operators": { + "level": "warn" + }, + "spacing_after_comma": { + "level": "warn" + }, + "transform_messes_up_line_numbers": { + "level": "warn" + } +} diff --git a/spec/index-spec.js b/spec/index-spec.js new file mode 100644 index 0000000..06af409 --- /dev/null +++ b/spec/index-spec.js @@ -0,0 +1,38 @@ +const fs = require('fs'); +const coffeelint = require('coffeelint'); +const config = require('../'); + +const validSrc = fs.readFileSync('./spec/valid.coffee', 'utf8'); +const invalidSrc = fs.readFileSync('./spec/invalid.coffee', 'utf8'); + +describe('Lint result for valid CoffeeScript file', () => { + + let res; + + beforeAll(() => { + res = coffeelint.lint(validSrc, config); + }); + it('has no errors', () => { + expect(res.length).toBeFalsy(); + }); +}); + +describe('Lint result for invalid CoffeeScript file', () => { + + let res; + + beforeAll(() => { + res = coffeelint.lint(invalidSrc, config); + }); + it('has errors', () => { + expect(res.length).toBeTruthy(); + }); + it('has error for rule "camel_case_classes"', () => { + expect(res[0].rule).toBe('camel_case_classes'); + expect(res[0].level).toBe('error'); + }); + it('has warning for rule "space_operators"', () => { + expect(res[1].rule).toBe('space_operators'); + expect(res[1].level).toBe('warn'); + }); +}); diff --git a/spec/invalid.coffee b/spec/invalid.coffee new file mode 100644 index 0000000..ba386d4 --- /dev/null +++ b/spec/invalid.coffee @@ -0,0 +1,9 @@ + +class duck + constructor: (name='Anonimous') -> + @name = name + quack: -> + @name + ' Duck: Quack-quack!' + +donald = new duck 'Donald' +console.log donald.quack() diff --git a/spec/valid.coffee b/spec/valid.coffee new file mode 100644 index 0000000..d691a8a --- /dev/null +++ b/spec/valid.coffee @@ -0,0 +1,6 @@ + +class Duck + constructor: (name = 'Anonimous') -> + @name = name + quack: -> + @name + ' Duck: Quack-quack!'