From 9a57976f0989606f360e94cb6e34f70a65034e0c Mon Sep 17 00:00:00 2001 From: Vladimir Date: Tue, 14 Dec 2021 22:02:51 +0600 Subject: [PATCH] Release v1.0.0 --- CHANGELOG.md | 10 +- LICENSE.md | 2 +- README.md | 28 +--- index.js | 7 + package.json | 33 +++-- recommended.json | 135 ------------------ rules/possible-errors.json | 15 ++ rules/stylistic-issues.json | 33 +++++ .../camel_case_classes/invalid.coffee | 9 ++ .../camel_case_classes}/valid.coffee | 0 .../space_operators}/invalid.coffee | 2 +- spec/fixtures/space_operators/valid.coffee | 6 + spec/index-spec.js | 109 +++++++++----- 13 files changed, 177 insertions(+), 212 deletions(-) create mode 100644 index.js delete mode 100644 recommended.json create mode 100644 rules/possible-errors.json create mode 100644 rules/stylistic-issues.json create mode 100644 spec/fixtures/camel_case_classes/invalid.coffee rename spec/{ => fixtures/camel_case_classes}/valid.coffee (100%) rename spec/{ => fixtures/space_operators}/invalid.coffee (93%) create mode 100644 spec/fixtures/space_operators/valid.coffee diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c229c3..dafc445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ -## 0.1.0 - First Release +## [1.0.0] - 2021-12-14 -* Initial release +- Update configuration +- Update logic +- Update Jasmine tests + +## [0.1.0] - First Release + +- Initial release diff --git a/LICENSE.md b/LICENSE.md index 2dc0f03..b28a11e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2018, DopustimVladimir +Copyright (c) 2021, 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. diff --git a/README.md b/README.md index 3fc73eb..d0912d9 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,13 @@ 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) +[![NPM](https://img.shields.io/npm/dt/@dopustim/coffeelint-config?style=flat-square)](https://www.npmjs.com/package/@dopustim/coffeelint-config) ## Features - Provide Errors and Warnings - 4 spaces for indentation (warning) -- 100 symbols per line (warning) +- 90 symbols per line (warning) - Unix linebreaks (warning) ## Usage @@ -23,10 +17,10 @@ Configuration file for CoffeeLint Install `@dopustim/coffeelint-config` package via [NPM](https://www.npmjs.com/package/@dopustim/coffeelint-config): ```sh -$ npm i -D coffeelint @dopustim/coffeelint-config +npm install -D coffeelint @dopustim/coffeelint-config ``` -Extend this config in your `coffeelint.json`: +Extend this config in your `.coffeelintrc.json`: ```json { @@ -47,18 +41,10 @@ You can also reassign any rule for your needs: ```json { "extends": "@dopustim/coffeelint-config", - "rules": { - "space_operators": { - "level": "ignore" - } - } + "max_line_length": { "value": 100, "limitComments": true, "level": "warn" } } ``` -## Rules - -You can find all rules on [official site](http://www.coffeelint.org/#options). - -## License +## About -[ISC License](./LICENSE.md) © 2018 Dopustim Vladimir +Visit the [CoffeeLint website](https://coffeelint.github.io) to find out all rules and descriptions. diff --git a/index.js b/index.js new file mode 100644 index 0000000..07445cb --- /dev/null +++ b/index.js @@ -0,0 +1,7 @@ +const possibleErrors = require("./rules/possible-errors.json") +const stylisticIssues = require("./rules/stylistic-issues.json") + +module.exports = { + ...possibleErrors, + ...stylisticIssues +} diff --git a/package.json b/package.json index 3c4632b..c36a4f6 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,30 @@ { "name": "@dopustim/coffeelint-config", - "version": "0.1.0", + "version": "1.0.0", "description": "Configuration file for CoffeeLint", - "keywords": [ - "configuration", - "config", - "json", - "validate", - "lint", - "linter", - "coffeelint" - ], + "keywords": [ "dopustim", "coffeelint", "config", "validate", "lint", "linter" ], "author": "DopustimVladimir", "license": "ISC", "repository": "https://github.com/dopustim/coffeelint-config", - "main": "recommended.json", + "main": "index.js", "scripts": { - "test": "jasmine spec/index-spec.js" + "test": "jasmine spec/*-spec.js" }, "devDependencies": { - "coffeelint": "^2.1.0", - "jasmine": "^3.3.0" + "jasmine": "^3.10.0", + "@coffeelint/cli": "^5.2.1", + "eslint": "^8.4.1" + }, + "eslintConfig": { + "extends": "@dopustim/eslint-config", + "env": { + "jasmine": true, + "es2020": true, + "node": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 2020 + } } } diff --git a/recommended.json b/recommended.json deleted file mode 100644 index 7a9ee4a..0000000 --- a/recommended.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "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/rules/possible-errors.json b/rules/possible-errors.json new file mode 100644 index 0000000..8b923a5 --- /dev/null +++ b/rules/possible-errors.json @@ -0,0 +1,15 @@ +{ + "coffeescript_error": { "level": "error" }, + "cyclomatic_complexity": { "value": 10, "level": "warn" }, + "duplicate_key": { "level": "error" }, + "indentation": { "value": 4, "level": "warn" }, + "line_endings": { "value": "unix", "level": "warn" }, + "missing_fat_arrows": { "is_strict": false, "level": "ignore" }, + "missing_parseint_radix": { "level": "warn" }, + "no_backticks": { "level": "error" }, + "no_debugger": { "console": false, "level": "error" }, + "no_empty_functions": { "level": "ignore" }, + "no_interpolation_in_single_quotes": { "level": "warn" }, + "no_nested_string_interpolation": { "level": "error" }, + "no_throwing_strings": { "level": "error" } +} \ No newline at end of file diff --git a/rules/stylistic-issues.json b/rules/stylistic-issues.json new file mode 100644 index 0000000..5908145 --- /dev/null +++ b/rules/stylistic-issues.json @@ -0,0 +1,33 @@ +{ + "arrow_spacing": { "level": "warn" }, + "braces_spacing": { "spaces": 1, "empty_object_spaces": 0, "level": "warn" }, + "bracket_spacing": { "level": "ignore" }, + "camel_case_classes": { "level": "warn" }, + "colon_assignment_spacing": { "spacing": { "left": 0, "right": 1 }, "level": "warn" }, + "empty_constructor_needs_parens": { "level": "ignore" }, + "ensure_comprehensions": { "level": "warn" }, + "eol_last": { "level": "warn" }, + "max_line_length": { "value": 90, "limitComments": true, "level": "warn" }, + "newlines_after_classes": { "value": 1, "level": "warn" }, + "no_empty_param_list": { "level": "ignore" }, + "no_implicit_braces": { "strict": false, "level": "ignore" }, + "no_implicit_parens": { "strict": false, "level": "ignore" }, + "no_plusplus": { "level": "ignore" }, + "no_private_function_fat_arrows": { "level": "warn" }, + "no_spaces": { "level": "ignore" }, + "no_stand_alone_at": { "level": "ignore" }, + "no_tabs": { "level": "warn" }, + "no_this": { "level": "warn" }, + "no_trailing_semicolons": { "level": "warn" }, + "no_trailing_whitespace": { "allowed_in_comments": false, "allowed_in_empty_lines": true, "level": "warn" }, + "no_unnecessary_double_quotes": { "level": "warn" }, + "no_unnecessary_fat_arrows": { "level": "warn" }, + "non_empty_constructor_needs_parens": { "level": "ignore" }, + "object_shorthand": { "level": "ignore" }, + "prefer_english_operator": { "doubleNotLevel": "ignore", "level": "warn" }, + "prefer_fat_arrows_in_methods": { "level": "ignore" }, + "prefer_logical_operator": { "level": "ignore" }, + "space_operators": { "level": "warn" }, + "spacing_after_comma": { "level": "warn" }, + "transform_messes_up_line_numbers": { "level": "warn" } +} \ No newline at end of file diff --git a/spec/fixtures/camel_case_classes/invalid.coffee b/spec/fixtures/camel_case_classes/invalid.coffee new file mode 100644 index 0000000..14f4b71 --- /dev/null +++ b/spec/fixtures/camel_case_classes/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/fixtures/camel_case_classes/valid.coffee similarity index 100% rename from spec/valid.coffee rename to spec/fixtures/camel_case_classes/valid.coffee diff --git a/spec/invalid.coffee b/spec/fixtures/space_operators/invalid.coffee similarity index 93% rename from spec/invalid.coffee rename to spec/fixtures/space_operators/invalid.coffee index ba386d4..16261ee 100644 --- a/spec/invalid.coffee +++ b/spec/fixtures/space_operators/invalid.coffee @@ -1,5 +1,5 @@ -class duck +class Duck constructor: (name='Anonimous') -> @name = name quack: -> diff --git a/spec/fixtures/space_operators/valid.coffee b/spec/fixtures/space_operators/valid.coffee new file mode 100644 index 0000000..d691a8a --- /dev/null +++ b/spec/fixtures/space_operators/valid.coffee @@ -0,0 +1,6 @@ + +class Duck + constructor: (name = 'Anonimous') -> + @name = name + quack: -> + @name + ' Duck: Quack-quack!' diff --git a/spec/index-spec.js b/spec/index-spec.js index 06af409..35eae29 100644 --- a/spec/index-spec.js +++ b/spec/index-spec.js @@ -1,38 +1,71 @@ -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'); - }); -}); +const coffeelint = require("coffeelint") +const config = require("../") +const fs = require("fs") + +describe("With rule \"camel_case_classes\"", () => { + + const validFile = "./spec/fixtures/camel_case_classes/valid.coffee" + const invalidFile = "./spec/fixtures/camel_case_classes/invalid.coffee" + + let res + + describe("valid file", () => { + + beforeAll(() => { + const source = fs.readFileSync(validFile, "utf8") + res = coffeelint.lint(source, config) + }) + it("has no errors or warnings", () => { + expect(res.length).toBeFalsy() + }) + }) + + describe("invalid file", () => { + + beforeAll(() => { + const source = fs.readFileSync(invalidFile, "utf8") + res = coffeelint.lint(source, config) + }) + it("has errors or warnings", () => { + 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") + }) + }) +}) + +describe("With rule \"space_operators\"", () => { + + const validFile = "./spec/fixtures/space_operators/valid.coffee" + const invalidFile = "./spec/fixtures/space_operators/invalid.coffee" + + let res + + describe("valid file", () => { + + beforeAll(() => { + const source = fs.readFileSync(validFile, "utf8") + res = coffeelint.lint(source, config) + }) + it("has no errors or warnings", () => { + expect(res.length).toBeFalsy() + }) + }) + + describe("invalid file", () => { + + beforeAll(() => { + const source = fs.readFileSync(invalidFile, "utf8") + res = coffeelint.lint(source, config) + }) + it("has errors or warnings", () => { + expect(res.length).toBeTruthy() + }) + it("has warn for rule \"space_operators\"", () => { + expect(res[0].rule).toBe("space_operators") + expect(res[0].level).toBe("warn") + }) + }) +})