From 5d5681bffea5b8cf3678d6677d99f9a752792e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Zrim=C5=A1ek?= Date: Wed, 5 Oct 2016 14:12:19 +0200 Subject: [PATCH] Added code semantic and style checking for JS, ERB, and SCSS files. JS, ERB and RUBY checkers were also bound to Hound. --- .eslintrc.json | 34 +++++++ .gitignore | 3 + .hound.yml | 7 ++ .jsbeautifyrc | 6 ++ .scss-lint.yml | 258 +++++++++++++++++++++++++++++++++++++++++++++++++ Gemfile | 1 + package.json | 26 +++++ 7 files changed, 335 insertions(+) create mode 100644 .eslintrc.json create mode 100644 .jsbeautifyrc create mode 100644 .scss-lint.yml create mode 100644 package.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..ba9f22d68 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,34 @@ +{ + "extends": "google", + "env": { + "browser": true, + "jquery": true + }, + "rules": { + "spaced-comment": [ + "error", + "always", + { + "markers": [ + "=" + ] + } + ], + "lines-around-comment": [ + "warn", + { + "beforeLineComment": false + } + ], + "quotes": [ + "error", + "single", + { + "avoidEscape": true + } + ] + }, + "globals": { + "_": true + } +} diff --git a/.gitignore b/.gitignore index fe99020cf..33ee9b01f 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ tags # Ignore rubocop cache files rubocop_cache + +# Ignore ESLint local instalation +node_modules diff --git a/.hound.yml b/.hound.yml index 5d0ff60bb..079bcf510 100644 --- a/.hound.yml +++ b/.hound.yml @@ -1,2 +1,9 @@ ruby: config_file: .rubocop.yml + +eslint: + enabled: true + config_file: .eslintrc.json + +scss: + config_file: .scss-lint.yml diff --git a/.jsbeautifyrc b/.jsbeautifyrc new file mode 100644 index 000000000..2e6d6dbb2 --- /dev/null +++ b/.jsbeautifyrc @@ -0,0 +1,6 @@ +{ + "erb": { + "indent_size": 2, + "wrap_line_length": 80 + } +} diff --git a/.scss-lint.yml b/.scss-lint.yml new file mode 100644 index 000000000..4bf19fc8c --- /dev/null +++ b/.scss-lint.yml @@ -0,0 +1,258 @@ +# Default application configuration that all configurations inherit from. + +scss_files: "app/assets/javascripts/**/*.scss" +plugin_directories: ['.scss-linters'] + +# List of gem names to load custom linters from (make sure they are already +# installed) +plugin_gems: [] + +# Default severity of all linters. +severity: warning + +linters: + BangFormat: + enabled: true + space_before_bang: true + space_after_bang: false + + BemDepth: + enabled: false + max_elements: 1 + + BorderZero: + enabled: true + convention: zero # or `none` + + ChainedClasses: + enabled: false + + ColorKeyword: + enabled: true + + ColorVariable: + enabled: true + + Comment: + enabled: true + style: silent + + DebugStatement: + enabled: true + + DeclarationOrder: + enabled: true + + DisableLinterReason: + enabled: false + + DuplicateProperty: + enabled: true + + ElsePlacement: + enabled: true + style: same_line # or 'new_line' + + EmptyLineBetweenBlocks: + enabled: true + ignore_single_line_blocks: true + + EmptyRule: + enabled: true + + ExtendDirective: + enabled: false + + FinalNewline: + enabled: true + present: true + + HexLength: + enabled: true + style: short # or 'long' + + HexNotation: + enabled: true + style: lowercase # or 'uppercase' + + HexValidation: + enabled: true + + IdSelector: + enabled: true + + ImportantRule: + enabled: true + + ImportPath: + enabled: true + leading_underscore: false + filename_extension: false + + Indentation: + enabled: true + allow_non_nested_indentation: false + character: space # or 'tab' + width: 2 + + LeadingZero: + enabled: true + style: exclude_zero # or 'include_zero' + + MergeableSelector: + enabled: true + force_nesting: true + + NameFormat: + enabled: true + allow_leading_underscore: true + convention: hyphenated_lowercase # or 'camel_case', or 'snake_case', or a regex pattern + + NestingDepth: + enabled: true + max_depth: 3 + ignore_parent_selectors: false + + PlaceholderInExtend: + enabled: true + + PrivateNamingConvention: + enabled: false + prefix: _ + + PropertyCount: + enabled: false + include_nested: false + max_properties: 10 + + PropertySortOrder: + enabled: true + ignore_unspecified: false + min_properties: 2 + separate_groups: false + + PropertySpelling: + enabled: true + extra_properties: [] + disabled_properties: [] + + PropertyUnits: + enabled: true + global: [ + 'ch', 'em', 'ex', 'rem', # Font-relative lengths + 'cm', 'in', 'mm', 'pc', 'pt', 'px', 'q', # Absolute lengths + 'vh', 'vw', 'vmin', 'vmax', # Viewport-percentage lengths + 'deg', 'grad', 'rad', 'turn', # Angle + 'ms', 's', # Duration + 'Hz', 'kHz', # Frequency + 'dpi', 'dpcm', 'dppx', # Resolution + '%'] # Other + properties: {} + + PseudoElement: + enabled: true + + QualifyingElement: + enabled: true + allow_element_with_attribute: false + allow_element_with_class: false + allow_element_with_id: false + + SelectorDepth: + enabled: true + max_depth: 3 + + SelectorFormat: + enabled: true + convention: hyphenated_lowercase # or 'strict_BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern + + Shorthand: + enabled: true + allowed_shorthands: [1, 2, 3, 4] + + SingleLinePerProperty: + enabled: true + allow_single_line_rule_sets: true + + SingleLinePerSelector: + enabled: true + + SpaceAfterComma: + enabled: true + style: one_space # or 'no_space', or 'at_least_one_space' + + SpaceAfterComment: + enabled: false + style: one_space # or 'no_space', or 'at_least_one_space' + allow_empty_comments: true + + SpaceAfterPropertyColon: + enabled: true + style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned' + + SpaceAfterPropertyName: + enabled: true + + SpaceAfterVariableColon: + enabled: false + style: one_space # or 'no_space', 'at_least_one_space' or 'one_space_or_newline' + + SpaceAfterVariableName: + enabled: true + + SpaceAroundOperator: + enabled: true + style: one_space # or 'at_least_one_space', or 'no_space' + + SpaceBeforeBrace: + enabled: true + style: space # or 'new_line' + allow_single_line_padding: false + + SpaceBetweenParens: + enabled: true + spaces: 0 + + StringQuotes: + enabled: true + style: single_quotes # or double_quotes + + TrailingSemicolon: + enabled: true + + TrailingWhitespace: + enabled: true + + TrailingZero: + enabled: false + + TransitionAll: + enabled: false + + UnnecessaryMantissa: + enabled: true + + UnnecessaryParentReference: + enabled: true + + UrlFormat: + enabled: true + + UrlQuotes: + enabled: true + + VariableForProperty: + enabled: false + properties: [] + + VendorPrefix: + enabled: true + identifier_list: base + additional_identifiers: [] + excluded_identifiers: [] + + ZeroUnit: + enabled: true + + Compass::*: + enabled: false diff --git a/Gemfile b/Gemfile index 0d3e8260b..fcc8643fc 100644 --- a/Gemfile +++ b/Gemfile @@ -64,6 +64,7 @@ group :development, :test do gem 'binding_of_caller' gem 'awesome_print' gem 'rubocop', require: false + gem 'scss_lint', require: false gem 'starscope', require: false end diff --git a/package.json b/package.json new file mode 100644 index 000000000..15ac89fae --- /dev/null +++ b/package.json @@ -0,0 +1,26 @@ +{ + "name": "scinote-web", + "version": "1.0.0", + "description": "![sciNote logo](http://scinote.net/wp-content/uploads/2015/10/logo_sciNote_final.png)", + "main": "application.js", + "repository": { + "type": "git", + "url": "git+https://github.com/biosistemika/scinote-web.git" + }, + "author": "SEE AUTHORS AT https://github.com/biosistemika/scinote-web/graphs/contributors", + "license": "SEE LICENSE IN LICENSE.txt", + "bugs": { + "url": "https://scinote.atlassian.net/" + }, + "homepage": "https://github.com/biosistemika/scinote-web#readme", + "files": [ + ".eslintrc.json" + ], + "scripts": { + "lint": "eslint ." + }, + "devDependencies": { + "eslint": "^3.7.1", + "eslint-config-google": "^0.5.0" + } +}