From 5ca36db3efddc2b64148fa575bf49b25dc1ed4d9 Mon Sep 17 00:00:00 2001 From: tenretC Date: Tue, 6 Mar 2018 14:39:08 +0100 Subject: [PATCH] #18 Added files, dependencies, scripts for prettier, tslint, stylelint, codelyzer in all parts (root, stark-build, starter) --- .prettierignore | 1 + .prettierrc | 22 - .prettierrc.js | 1 + .stylelintrc | 435 +---------------- docs/PRETTIER.md | 36 ++ package.json | 4 +- .../stark-build/config-stark/webpack.dev.js | 2 +- packages/stark-build/config/.prettierrc.js | 22 + .../stark-build/config/stylelint.config.js | 437 ++++++++++++++++++ packages/stark-build/config/tslint.json | 352 ++++++++++++++ packages/stark-build/config/webpack.dev.js | 2 +- packages/stark-build/package.json | 7 + starter/.prettierignore | 7 + starter/.prettierrc.js | 1 + starter/.stylelintrc | 432 +---------------- starter/package.json | 10 +- starter/tslint.json | 42 +- tslint.json | 320 +------------ 18 files changed, 881 insertions(+), 1252 deletions(-) delete mode 100644 .prettierrc create mode 100644 .prettierrc.js create mode 100644 docs/PRETTIER.md create mode 100644 packages/stark-build/config/.prettierrc.js create mode 100644 packages/stark-build/config/stylelint.config.js create mode 100644 packages/stark-build/config/tslint.json create mode 100644 starter/.prettierignore create mode 100644 starter/.prettierrc.js diff --git a/.prettierignore b/.prettierignore index 144742bb1d..4ab4dcd918 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ +.git/ .github/ .idea/ .vscode/ diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 0270aa27fd..0000000000 --- a/.prettierrc +++ /dev/null @@ -1,22 +0,0 @@ -{ -"printWidth":140, -"tabWidth":4, -"useTabs":true, -"trailingComma":"none", -"overrides": [ - { - "files": "*.{pcss,scss,css,json}", - "options": { - "tabWidth": 2, - "useTabs":false - } - }, - { - "files": "{package.json,.travis.yml}", - "options": { - "tabWidth": 2, - "useTabs":false - } - } - ] -} diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..f5bb84bdd8 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require("./packages/stark-build/config/.prettierrc"); diff --git a/.stylelintrc b/.stylelintrc index 6b04966a5f..1864831619 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,436 +1,3 @@ { - "extends": [ - "stylelint-config-prettier" - ], - "defaultSeverity": "error", - "rules": { - "color-hex-case": [ - "lower", - { - "message": "Lowercase letters are easier to distinguish from numbers." - } - ], - "color-hex-length": [ - "short", - { - "message": "Use short hex codes when possible to avoid unnecessary code." - } - ], - "color-named": [ - "never", - { - "message": "No named colors are allowed because of consistency. Always use hex or rgba." - } - ], - "font-family-name-quotes": [ - "always-where-required", - { - "message": "Quotes are required around font-family names when they are not valid CSS identifiers." - } - ], - "font-family-no-duplicate-names": [ - true, - { - "message": "Avoid duplicate information." - } - ], - "font-family-no-missing-generic-family-keyword": [ - true, - { - "message": "Always put at least one generic font family." - } - ], - "function-comma-space-after": [ - "always", - { - "message": "Always put a space after commas in functions to be consistent and improve readability." - } - ], - "function-comma-space-before": [ - "never", - { - "message": "Never put spaces before a comma to be consistent and improve readability." - } - ], - "function-max-empty-lines": [ - 0, - { - "message": "Avoid empty lines in functions to improve readability." - } - ], - "function-name-case": [ - "lower", - { - "message": "Function names should be in lowercase following the CSS specification." - } - ], - "number-leading-zero": [ - "never", - { - "message": "Should not contain leading zeros to avoid unnecessary code." - } - ], - "number-no-trailing-zeros": [ - true, - { - "message": "Should not contain trailing zeros to avoid unnecessary code." - } - ], - "string-quotes": [ - "double", - { - "message": "Always use double quotes for consistency." - } - ], - "length-zero-no-unit": [ - true, - { - "message": "Zero value should never have a unit to avoid unnecessary code." - } - ], - "unit-case": [ - "lower", - { - "message": "Units should always be lowercase for consistency. Lower case is more readable." - } - ], - "unit-no-unknown": true, - "value-keyword-case": [ - "lower", - { - "message": "Keyword values should always be lowercase for consistency. Lower case is more readable." - } - ], - "value-no-vendor-prefix": [ - true, - { - "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." - } - ], - "value-list-comma-newline-before": [ - "never-multi-line", - { - "message": "In value lists, there should never be a space or a newline between a comma and a previous value." - } - ], - "value-list-comma-space-after": [ - "always-single-line", - { - "message": "In single line value lists, there should always be a space after each comma for better readability." - } - ], - "value-list-comma-space-before": [ - "never", - { - "message": "In value lists, there should never be a space or a newline between a comma and a previous value." - } - ], - "value-list-max-empty-lines": [ - 0, - { - "message": "Value lists should never contain empty lines to make them better visible as a group." - } - ], - "property-case": [ - "lower", - { - "message": "Properties should always be lowercase for consistency. Lower case is more readable." - } - ], - "property-no-unknown": true, - "property-no-vendor-prefix": [ - true, - { - "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." - } - ], - "keyframe-declaration-no-important": [ - true, - { - "message": "!important should only be used as a last resort and never in keyframe animations." - } - ], - "declaration-bang-space-after": [ - "never", - { - "message": "!important should never contain spaces." - } - ], - "declaration-bang-space-before": [ - "always", - { - "message": "!important should always be preceded by a space to improve readability." - } - ], - "declaration-colon-space-after": [ - "always", - { - "message": "Always add a space after a declaration colon to improve readability." - } - ], - "declaration-colon-space-before": [ - "never", - { - "message": "Never put a space between a declaration and the colon to avoid too much spaces." - } - ], - "declaration-block-no-duplicate-properties": [ - true, - { - "message": "All properties should only be defined once." - } - ], - "declaration-block-semicolon-newline-after": [ - "always", - { - "message": "Each property should be declared on a separate line to improve readability." - } - ], - "declaration-block-semicolon-newline-before": [ - "never-multi-line", - { - "message": "Never put a newline before a semicolon to avoid unnecessary whitespace." - } - ], - "declaration-block-semicolon-space-after": "always-single-line", - "declaration-block-semicolon-space-before": [ - "never", - { - "message": "Never put a space before a semicolon to avoid unnecessary whitespace." - } - ], - "declaration-block-trailing-semicolon": [ - "always", - { - "message": "The last declaration of a block should also include a semicolon to reduce errors when adding rules." - } - ], - "block-closing-brace-empty-line-before": [ - "never", - { - "message": "Never put a newline before a block closing bracket to avoid unnecessary whitespace." - } - ], - "block-closing-brace-newline-after": [ - "always", - { - "message": "Declaration blocks should always start on a new line to maximize readability." - } - ], - "block-closing-brace-newline-before": [ - "always-multi-line", - { - "message": "Always put a block closing bracket on a separate line for better readability." - } - ], - "block-opening-brace-newline-after": [ - "always-multi-line", - { - "message": "Always put a newline after a block opening bracket for better readability." - } - ], - "block-opening-brace-space-before": [ - "always", - { - "message": "Always put a space before a block opening bracket for better readability." - } - ], - "selector-attribute-brackets-space-inside": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-operator-space-after": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-operator-space-before": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-quotes": [ - "always", - { - "message": "Always put selector attribute values in quotes to be consistent and improve readability." - } - ], - "selector-combinator-space-after": [ - "always", - { - "message": "Always put spaces around selector combinators to improve readability." - } - ], - "selector-combinator-space-before": [ - "always", - { - "message": "Always put spaces around selector combinators to improve readability." - } - ], - "selector-descendant-combinator-no-non-space": [ - true, - { - "message": "Don't put tabs, newlines, nor multiple spaces between selector descendants to improve readability." - } - ], - "selector-max-id": [ - 0, - { - "message": "Never use #id as a selector: it is difficult to ensure ids are unique and because of their weight styles are difficult to override." - } - ], - "selector-pseudo-class-case": [ - "lower", - { - "message": "Always use lowercase for pseudo-class selectors for consistency and to improve readability." - } - ], - "selector-pseudo-class-no-unknown": true, - "selector-pseudo-element-case": [ - "lower", - { - "message": "Always use lowercase for pseudo-element selectors for consistency and to improve readability." - } - ], - "selector-pseudo-element-colon-notation": [ - "double", - { - "message": "Double colons (::) should be used instead of a single colon to distinguish pseudo-elements from pseudo-classes." - } - ], - "selector-pseudo-element-no-unknown": true, - "selector-type-case": [ - "lower", - { - "message": "Always use lowercase for tag name selectors for consistency and to improve readability." - } - ], - "selector-max-empty-lines": [ - 0, - { - "message": "Never put empty lines in selector blocks to improve readability and to avoid unnecessary whitespace." - } - ], - "selector-list-comma-newline-after": [ - "always", - { - "message": "Each selector has to be put on a separate line to improve readability." - } - ], - "selector-list-comma-newline-before": [ - "never-multi-line", - { - "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." - } - ], - "selector-list-comma-space-before": [ - "never", - { - "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." - } - ], - "media-feature-colon-space-after": [ - "always", - { - "message": "Always put a space after a media feature colon to improve readability." - } - ], - "media-feature-colon-space-before": [ - "never", - { - "message": "Never put a space before a media feature colon to avoid unnecessary whitespace." - } - ], - "media-feature-name-case": [ - "lower", - { - "message": "Always use lowercase for media feature names for consistency and to improve readability." - } - ], - "media-feature-name-no-unknown": true, - "media-feature-parentheses-space-inside": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "media-feature-range-operator-space-after": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "media-feature-range-operator-space-before": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "at-rule-empty-line-before": [ - "always", - { - "ignore": [ - "after-comment", - "blockless-after-same-name-blockless" - ], - "ignoreAtRules": [ - "import" - ], - "message": "Always put an empty line before each @ rule, except after a comment or for @import." - } - ], - "at-rule-name-case": [ - "lower", - { - "message": "Always use lowercase for @ rule names for consistency and to improve readability." - } - ], - "at-rule-name-space-after": [ - "always", - { - "message": "Always put a space after @ rule names for consistency and to improve readability." - } - ], - "at-rule-no-unknown": true, - "at-rule-semicolon-newline-after": [ - "always", - { - "message": "Always put a newline after the ending @ rule semicolon to improve readability." - } - ], - "at-rule-semicolon-space-before": [ - "never", - { - "message": "Never put a newline after the ending @ rule semicolon to avoid unnecessary whitespace." - } - ], - "no-duplicate-at-import-rules": [ - true, - { - "message": "Avoid duplicate @import rule within the same stylesheet." - } - ], - "no-extra-semicolons": [ - true, - { - "message": "No extra semicolons: they don't make sense." - } - ], - "no-invalid-double-slash-comments": [ - true, - { - "message": "In CSS, double slashes do not indicate a single line comment. Use /* */ instead." - } - ], - "no-unknown-animations": [ - true, - { - "message": "Check your code. The animation name \"${animationName}\" is not defined." - } - ] - } + "extends": "./packages/stark-build/config/stylelint.config.js" } diff --git a/docs/PRETTIER.md b/docs/PRETTIER.md new file mode 100644 index 0000000000..3676a25439 --- /dev/null +++ b/docs/PRETTIER.md @@ -0,0 +1,36 @@ +# Prettier + +> Specification for the package [Prettier](https://github.com/prettier/prettier) used in Stark + +## Basic features +Stark allows you to prettify your code with `Prettier`. +You can do it whenever you want with the script `prettier-check` +``` +$ npm run prettier-check +``` +## Prettier configuration +The main Prettier configuration file is located in `stark-build`. +The one located in `starter` and the other one located in the root just reference the `stark-build` configuration file +## Conflicts with TSLint and Stylelint +The configurations of `TSLint` and `Stylelint` can conflict with `Prettier`. +It's why we use [tslint-config-prettier](https://github.com/alexjoverm/tslint-config-prettier) and +[stylelint-config-prettier](https://github.com/shannonmoeller/stylelint-config-prettier) + +To check if your configuration of `TSLint` conflicts with `Prettier`, you can run the script `tslint-check` : +``` +$ npm run tslint-check +``` +To check if your configuration of `Stylelint` conflicts with `Prettier`, you can run the script `stylelint-check` : +``` +$ npm run stylelint-check +``` +By default, Stark tslint configuration extends tslint-config-prettier to avoid conflicts and +stylelint configuration extends stylelint-config-prettier for the same reason +## Ignored files +`.prettierignore` file contains all the files which won't be prettified by `Prettier` +## Git hook +Before every commit, `Prettier` will prettify all the modified code. +This is done by using [Husky](https://github.com/typicode/husky) +and [Lint-staged](https://github.com/okonet/lint-staged) to execute `Prettier` +for every changed files before every commit so you won't need to execute it manually +before you commit your code \ No newline at end of file diff --git a/package.json b/package.json index 7d08c64158..2157b879cc 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "devDependencies": { "@angular/compiler": "5.2.6", "@angular/compiler-cli": "5.2.6", + "codelyzer": "4.2.1", "husky": "0.14.3", "lint-staged": "7.0.0", "prettier": "1.10.2", @@ -28,7 +29,7 @@ "rollup-plugin-node-resolve": "3.0.3", "rollup-plugin-sourcemaps": "0.4.2", "stylelint": "9.1.1", - "stylelint-config-prettier": "2.1.0", + "stylelint-config-prettier": "3.0.4", "tslint": "5.9.1", "tslint-config-prettier": "1.8.0", "typescript": "2.6.2", @@ -39,6 +40,7 @@ "prettier-check": "prettier **/*.{css,js,json,pcss,scss,ts} --write", "tslint": "tslint", "tslint-check": "tslint-config-prettier-check ./tslint.json", + "stylelint-check": "stylelint-config-prettier-check", "tsc": "tsc", "ngc": "ngc", "postinstall": "npm run postinstall:build && npm run postinstall:core && npm run build && npm run postinstall:starter", diff --git a/packages/stark-build/config-stark/webpack.dev.js b/packages/stark-build/config-stark/webpack.dev.js index 132c6e0573..c3e1c6b467 100644 --- a/packages/stark-build/config-stark/webpack.dev.js +++ b/packages/stark-build/config-stark/webpack.dev.js @@ -219,7 +219,7 @@ module.exports = webpackMerge(commonConfig, { // Description: Lints the stylesheets loaded in the app (pcss, scss, css, sass) // reference https://github.com/JaKXz/stylelint-webpack-plugin new StylelintPlugin({ - configFile: ".stylelintrc", + configFile: "stylelint.config.js", emitErrors: false, files: ["src/**/*.?(pc|sc|c|sa)ss"] // pcss|scss|css|sass }), diff --git a/packages/stark-build/config/.prettierrc.js b/packages/stark-build/config/.prettierrc.js new file mode 100644 index 0000000000..0b8d7af4c9 --- /dev/null +++ b/packages/stark-build/config/.prettierrc.js @@ -0,0 +1,22 @@ +module.exports = { + printWidth: 140, + tabWidth: 4, + useTabs: true, + trailingComma: "none", + overrides: [ + { + files: "*.{pcss,scss,css,json}", + options: { + tabWidth: 2, + useTabs: false + } + }, + { + files: ".travis.yml", + options: { + tabWidth: 2, + useTabs: false + } + } + ] +}; diff --git a/packages/stark-build/config/stylelint.config.js b/packages/stark-build/config/stylelint.config.js new file mode 100644 index 0000000000..4c3d190810 --- /dev/null +++ b/packages/stark-build/config/stylelint.config.js @@ -0,0 +1,437 @@ +module.exports = { + extends: "stylelint-config-prettier", + defaultSeverity: "error", + rules: { + "color-hex-length": [ + "short", + { + "message": "Use short hex codes when possible to avoid unnecessary code." + } + ], + "color-named": [ + "never", + { + "message": "No named colors are allowed because of consistency. Always use hex or rgba." + } + ], + "font-family-name-quotes": [ + "always-where-required", + { + "message": "Quotes are required around font-family names when they are not valid CSS identifiers." + } + ], + "font-family-no-duplicate-names": [ + true, + { + "message": "Avoid duplicate information." + } + ], + "font-family-no-missing-generic-family-keyword": [ + true, + { + "message": "Always put at least one generic font family." + } + ], + "function-name-case": [ + "lower", + { + "message": "Function names should be in lowercase following the CSS specification." + } + ], + "string-quotes": [ + "double", + { + "message": "Always use double quotes for consistency." + } + ], + "length-zero-no-unit": [ + true, + { + "message": "Zero value should never have a unit to avoid unnecessary code." + } + ], + "unit-no-unknown": true, + "value-keyword-case": [ + "lower", + { + "message": "Keyword values should always be lowercase for consistency. Lower case is more readable." + } + ], + "value-no-vendor-prefix": [ + true, + { + "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." + } + ], + "property-no-unknown": true, + "property-no-vendor-prefix": [ + true, + { + "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." + } + ], + "keyframe-declaration-no-important": [ + true, + { + "message": "!important should only be used as a last resort and never in keyframe animations." + } + ], + "declaration-block-no-duplicate-properties": [ + true, + { + "message": "All properties should only be defined once." + } + ], + "selector-attribute-operator-space-after": [ + "never", + { + "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." + } + ], + "selector-attribute-operator-space-before": [ + "never", + { + "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." + } + ], + "selector-max-id": [ + 0, + { + "message": "Never use #id as a selector: it is difficult to ensure ids are unique and because of their weight styles are difficult to override." + } + ], + "selector-pseudo-class-no-unknown": true, + "selector-pseudo-element-colon-notation": [ + "double", + { + "message": "Double colons (::) should be used instead of a single colon to distinguish pseudo-elements from pseudo-classes." + } + ], + "selector-pseudo-element-no-unknown": true, + "selector-type-case": [ + "lower", + { + "message": "Always use lowercase for tag name selectors for consistency and to improve readability." + } + ], + "media-feature-name-no-unknown": true, + "media-feature-range-operator-space-after": [ + "never", + { + "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." + } + ], + "media-feature-range-operator-space-before": [ + "never", + { + "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." + } + ], + "at-rule-empty-line-before": [ + "always", + { + "ignore": [ + "after-comment", + "blockless-after-same-name-blockless" + ], + "ignoreAtRules": [ + "import" + ], + "message": "Always put an empty line before each @ rule, except after a comment or for @import." + } + ], + "at-rule-no-unknown": true, + "no-duplicate-at-import-rules": [ + true, + { + "message": "Avoid duplicate @import rule within the same stylesheet." + } + ], + "no-invalid-double-slash-comments": [ + true, + { + "message": "In CSS, double slashes do not indicate a single line comment. Use /* */ instead." + } + ], + "no-unknown-animations": [ + true, + { + "message": "Check your code. The animation name \"${animationName}\" is not defined." + } + ] + } + + /*These rules are handled by Prettier + "function-comma-space-after": [ + "always", + { + "message": "Always put a space after commas in functions to be consistent and improve readability." + } + ], + "function-comma-space-before": [ + "never", + { + "message": "Never put spaces before a comma to be consistent and improve readability." + } + ], + "function-max-empty-lines": [ + 0, + { + "message": "Avoid empty lines in functions to improve readability." + } + ], + "value-list-comma-newline-before": [ + "never-multi-line", + { + "message": "In value lists, there should never be a space or a newline between a comma and a previous value." + } + ], + "value-list-comma-space-after": [ + "always-single-line", + { + "message": "In single line value lists, there should always be a space after each comma for better readability." + } + ], + "value-list-comma-space-before": [ + "never", + { + "message": "In value lists, there should never be a space or a newline between a comma and a previous value." + } + ], + "value-list-max-empty-lines": [ + 0, + { + "message": "Value lists should never contain empty lines to make them better visible as a group." + } + ], + "declaration-bang-space-after": [ + "never", + { + "message": "!important should never contain spaces." + } + ], + "declaration-bang-space-before": [ + "always", + { + "message": "!important should always be preceded by a space to improve readability." + } + ], + "declaration-colon-space-after": [ + "always", + { + "message": "Always add a space after a declaration colon to improve readability." + } + ], + "declaration-colon-space-before": [ + "never", + { + "message": "Never put a space between a declaration and the colon to avoid too much spaces." + } + ], + "declaration-block-semicolon-newline-after": [ + "always", + { + "message": "Each property should be declared on a separate line to improve readability." + } + ], + "declaration-block-semicolon-newline-before": [ + "never-multi-line", + { + "message": "Never put a newline before a semicolon to avoid unnecessary whitespace." + } + ], + "declaration-block-semicolon-space-after": "always-single-line", + "declaration-block-semicolon-space-before": [ + "never", + { + "message": "Never put a space before a semicolon to avoid unnecessary whitespace." + } + ], + "declaration-block-trailing-semicolon": [ + "always", + { + "message": "The last declaration of a block should also include a semicolon to reduce errors when adding rules." + } + ], + "block-closing-brace-empty-line-before": [ + "never", + { + "message": "Never put a newline before a block closing bracket to avoid unnecessary whitespace." + } + ], + "block-closing-brace-newline-after": [ + "always", + { + "message": "Declaration blocks should always start on a new line to maximize readability." + } + ], + "block-closing-brace-newline-before": [ + "always-multi-line", + { + "message": "Always put a block closing bracket on a separate line for better readability." + } + ], + "block-opening-brace-newline-after": [ + "always-multi-line", + { + "message": "Always put a newline after a block opening bracket for better readability." + } + ], + "block-opening-brace-space-before": [ + "always", + { + "message": "Always put a space before a block opening bracket for better readability." + } + ], + "selector-attribute-brackets-space-inside": [ + "never", + { + "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." + } + ], + "selector-attribute-quotes": [ + "always", + { + "message": "Always put selector attribute values in quotes to be consistent and improve readability." + } + ], + "selector-combinator-space-after": [ + "always", + { + "message": "Always put spaces around selector combinators to improve readability." + } + ], + "selector-combinator-space-before": [ + "always", + { + "message": "Always put spaces around selector combinators to improve readability." + } + ], + "selector-descendant-combinator-no-non-space": [ + true, + { + "message": "Don't put tabs, newlines, nor multiple spaces between selector descendants to improve readability." + } + ], + "selector-list-comma-newline-after": [ + "always", + { + "message": "Each selector has to be put on a separate line to improve readability." + } + ], + "selector-list-comma-newline-before": [ + "never-multi-line", + { + "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." + } + ], + "selector-list-comma-space-before": [ + "never", + { + "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." + } + ], + "media-feature-colon-space-after": [ + "always", + { + "message": "Always put a space after a media feature colon to improve readability." + } + ], + "media-feature-colon-space-before": [ + "never", + { + "message": "Never put a space before a media feature colon to avoid unnecessary whitespace." + } + ], + "media-feature-parentheses-space-inside": [ + "never", + { + "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." + } + ], + "at-rule-name-space-after": [ + "always", + { + "message": "Always put a space after @ rule names for consistency and to improve readability." + } + ], + "at-rule-semicolon-newline-after": [ + "always", + { + "message": "Always put a newline after the ending @ rule semicolon to improve readability." + } + ], + "at-rule-semicolon-space-before": [ + "never", + { + "message": "Never put a newline after the ending @ rule semicolon to avoid unnecessary whitespace." + } + ], + "number-leading-zero": [ + "never", + { + "message": "Should not contain leading zeros to avoid unnecessary code." + } + ], + "color-hex-case": [ + "lower", + { + "message": "Lowercase letters are easier to distinguish from numbers." + } + ], + "number-no-trailing-zeros": [ + true, + { + "message": "Should not contain trailing zeros to avoid unnecessary code." + } + ], + "unit-case": [ + "lower", + { + "message": "Units should always be lowercase for consistency. Lower case is more readable." + } + ], + "property-case": [ + "lower", + { + "message": "Properties should always be lowercase for consistency. Lower case is more readable." + } + ], + "selector-pseudo-class-case": [ + "lower", + { + "message": "Always use lowercase for pseudo-class selectors for consistency and to improve readability." + } + ], + "selector-pseudo-element-case": [ + "lower", + { + "message": "Always use lowercase for pseudo-element selectors for consistency and to improve readability." + } + ], + "selector-max-empty-lines": [ + 0, + { + "message": "Never put empty lines in selector blocks to improve readability and to avoid unnecessary whitespace." + } + ], + "media-feature-name-case": [ + "lower", + { + "message": "Always use lowercase for media feature names for consistency and to improve readability." + } + ], + "at-rule-name-case": [ + "lower", + { + "message": "Always use lowercase for @ rule names for consistency and to improve readability." + } + ], + "no-extra-semicolons": [ + true, + { + "message": "No extra semicolons: they don't make sense." + } + ] + */ +} diff --git a/packages/stark-build/config/tslint.json b/packages/stark-build/config/tslint.json new file mode 100644 index 0000000000..1facf24487 --- /dev/null +++ b/packages/stark-build/config/tslint.json @@ -0,0 +1,352 @@ +{ + "extends": ["tslint:latest","tslint-config-prettier", "codelyzer"], + "defaultSeverity": "error", + "rules": { + // Codelyzer recommended rules + "directive-selector": [true, "attribute", "", "kebab-case"], + "component-selector": [true, "element", "", "kebab-case"], + "angular-whitespace": [true, "check-interpolation", "check-semicolon"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-attribute-parameter-decorator": true, + "no-input-rename": true, + "no-output-on-prefix": true, + "no-output-rename": true, + "no-forward-ref": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "no-output-named-after-standard-event": true, + "component-class-suffix": [true, "Component"], + "directive-class-suffix": [true, "Directive"], + + // Codelyzer rules + "banana-in-box": true, + "contextual-life-cycle": true, + "decorator-not-allowed": true, + "pipe-impure": true, + "templates-no-negated-async": true, + "use-pipe-decorator": true, + "use-view-encapsulation": true, + "trackBy-function": true, + "import-destructuring-spacing": true, + "no-unused-css": true, + "i18n": [true, "check-id", "check-text"], + "template-cyclomatic-complexity": [true, 5], + "template-conditional-complexity": [true, 4], + + // TSlint rules + "member-access": [true, "check-accessor", "check-constructor", "check-parameter-property"], + "member-ordering": [ + false, + { + "order": "fields-first" + } + ], + "no-any": false, + "no-empty-interface": false, + "no-inferrable-types": false, + "no-internal-module": true, + "no-namespace": [true, "allow-declarations"], + "no-reference": true, + "no-var-requires": false, + "typedef": [ + true, + "call-signature", + // "arrow-call-signature", + "parameter", + "arrow-parameter", + "property-declaration", + "variable-declaration", + "member-variable-declaration", + "object-destructuring", + "array-destructuring" + ], + "typedef-whitespace": [ + false, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + }, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "unified-signatures": true, + "ban": [ + true, + "window", + "eval", + { "name": ["angular", "bind"], "message": "Use Function bind() method" }, + { + "name": ["angular", "copy"], + "message": "Use Lodash cloneDeep() or Object/Array spread syntax" + }, + { + "name": ["angular", "equals"], + "message": "Use strict equality comparison (===)" + }, + { + "name": ["angular", "extend"], + "message": "Use Lodash merge() or Object spread syntax" + }, + { + "name": ["angular", "forEach"], + "message": "Use for...of loop, for...in loop or Array forEach()" + }, + { "name": ["angular", "fromJson"], "message": "Use JSON.parse()" }, + { + "name": ["angular", "isArray"], + "message": "Use Array.isArray() function" + }, + { + "name": ["angular", "isDate"], + "message": "Use moment.isDate() function" + }, + { + "name": ["angular", "isDefined"], + "message": "Use typeof operator (type guard)" + }, + { + "name": ["angular", "isFunction"], + "message": "Use typeof operator (type guard) or Lodash isFunction()" + }, + { + "name": ["angular", "isNumber"], + "message": "Use typeof operator (type guard) or Lodash isNumber()" + }, + { + "name": ["angular", "isString"], + "message": "Use typeof operator (type guard) or Lodash isString()" + }, + { + "name": ["angular", "isUndefined"], + "message": "Use typeof operator (type guard) or Lodash isUndefined()" + }, + { + "name": ["angular", "merge"], + "message": "Use Lodash merge() or cloneDeep()" + }, + { "name": ["angular", "noop"], "message": "Use Lodash noop()" }, + { "name": ["angular", "toJson"], "message": "Use JSON.stringify()" } + ], + "curly": true, + "forin": true, + "label-position": true, + "no-arg": true, + "no-bitwise": true, + "no-conditional-assignment": true, + "no-console": [false, "debug", "info", "time", "timeEnd", "trace"], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": [true, "allow-empty-catch"], + "no-eval": true, + "no-implicit-dependencies": false, + "no-invalid-template-strings": true, + "no-invalid-this": true, + "no-null-keyword": true, + "no-object-literal-type-assertion": true, + "no-return-await": true, + "no-shadowed-variable": true, + "no-sparse-arrays": true, + "no-string-literal": false, + "no-string-throw": false, + "no-submodule-imports": [false, "@nationalbankbelgium", "rxjs", "lodash", "core-js", "valdr", "angular-material"], + "no-switch-case-fall-through": true, + "no-this-assignment": false, + "no-unnecessary-class": ["allow-static-only"], + "no-unsafe-finally": true, + "no-unused-expression": true, + "no-var-keyword": true, + "prefer-conditional-expression": false, + "prefer-object-spread": true, + "prefer-template": false, + "radix": true, + "switch-default": true, + "triple-equals": true, + "use-isnan": true, + "cyclomatic-complexity": [true, 20], + "no-default-export": true, + "no-duplicate-imports": true, + "no-mergeable-namespace": true, + "no-require-imports": false, + "object-literal-sort-keys": false, + "align": [false, "arguments", "statements", "parameters", "members", "elements"], + "callable-types": true, + "class-name": true, + "comment-format": [false, "check-space"], + "encoding": false, + "interface-name": [false, "never-prefix"], + "interface-over-type-literal": true, + "jsdoc-format": false, + "no-angle-bracket-type-assertion": false, + "no-parameter-properties": true, + "no-redundant-jsdoc": false, + "no-reference-import": true, + "no-unnecessary-callback-wrapper": false, + "object-literal-shorthand": false, + "one-variable-per-declaration": true, + "switch-final-break": false, + "type-literal-delimiter": true, + "variable-name": [true, "check-format", "allow-leading-underscore", "allow-trailing-underscore", "ban-keywords"], + "whitespace": [ + false, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-rest-spread", + "check-type", + "check-typecast", + "check-type-operator", + "check-pre-block" + ], + "prefer-const": [ + true, + { + "destructuring": "all" + } + ], + "no-magic-numbers": false, + "import-blacklist": true, + "ordered-imports": false, + "max-classes-per-file": false, // [true, 1], + "prefer-for-of": true, + "array-type": false, // [true, "array"] + "arrow-return-shorthand": true, + "binary-expression-operand-order": false, + "no-unnecessary-initializer": true, + "no-misused-new": true, + "prefer-method-signature": false, + "prefer-switch": [ + true, + { + "min-cases": 3 + } + ], + "prefer-function-over-method": false, + "no-import-side-effect": [ + true, + { + "ignore-module": "(rxjs|reflect-metadata|core-js|ngrx-store|angular|polyfills|vendor|typings|\\.css|\\.pcss)" + } + ], + "no-non-null-assertion": true, + "no-parameter-reassignment": false, + "adjacent-overload-signatures": true, + "ban-comma-operator": false, + "ban-types": false, + "no-duplicate-super": true, + "no-duplicate-switch-case": true, + "newline-before-return": false + } + + //These rules require type info to run + // "strict-boolean-expressions": true, + // "promise-function-async": true, + // "no-inferred-empty-object-type": true, + // "no-void-expression": true, + // "completed-docs": true, + // "no-unbound-method": true, + // "no-boolean-literal-compare": true, + // "no-unsafe-any": true, + // "no-unnecessary-qualifier": true, + // "no-unnecessary-type-assertion": true, + // "no-use-before-declare": true, + // "await-promise": true, + // "no-floating-promises": true, + // "strict-type-predicates": true, + // "match-default-export-name": true, + // "return-undefined": true, + // "deprecation": true, + // "use-default-type-parameter": true, + // + //These rules are handled by Prettier + // "eofline": true, + // "import-spacing": true, + // "indent": [ + // false, + // "tabs", + // 2 + // ], + // "max-line-length": [ + // true, + // 140 + // ], + // "no-trailing-whitespace": false, + // "one-line": [ + // true, + // "check-catch", + // "check-finally", + // "check-else", + // "check-open-brace", + // "check-whitespace" + // ], + // "quotemark": [ + // true, + // "double", + // "avoid-escape" + // ], + // "semicolon": [ + // true, + // "always" + // ], + // "trailing-comma": [ + // false, + // { + // "multiline": { + // "objects": "always", + // "arrays": "always", + // "functions": "always", + // "imports": "always", + // "exports": "always", + // "typeLiterals": "ignore" + // }, + // "singleline": { + // "objects": "never", + // "arrays": "never", + // "functions": "never", + // "imports": "never", + // "exports": "never", + // "typeLiterals": "ignore" + // }, + // "esSpecCompliant": true + // } + // ], + // "space-before-function-paren": [ + // true, + // { + // "anonymous": "always", + // "named": "never", + // "asyncArrow": "never", + // "method": "never", + // "constructor": "never" + // } + // ], + // "space-within-parens": 0, + // "no-irregular-whitespace": true, + // "no-consecutive-blank-lines": [ + // true, + // 1 + // ], + // "arrow-parens": true, + // "linebreak-style": [ + // true, + // "LF" + // ], + // "new-parens": true, + // "number-literal-format": true, + // "object-literal-key-quotes": [ + // true, + // "as-needed" + // ], +} diff --git a/packages/stark-build/config/webpack.dev.js b/packages/stark-build/config/webpack.dev.js index 6497c8c2f4..d3998cd8c2 100644 --- a/packages/stark-build/config/webpack.dev.js +++ b/packages/stark-build/config/webpack.dev.js @@ -229,7 +229,7 @@ module.exports = function() { * See: https://github.com/JaKXz/stylelint-webpack-plugin */ new StylelintPlugin({ - configFile: ".stylelintrc", + configFile: "stylelint.config.js", emitErrors: false, files: ["src/**/*.?(pc|sc|c|sa)ss"] // pcss|scss|css|sass }) diff --git a/packages/stark-build/package.json b/packages/stark-build/package.json index d16f076876..d0947c1b3b 100644 --- a/packages/stark-build/package.json +++ b/packages/stark-build/package.json @@ -29,6 +29,7 @@ "angular2-template-loader": "0.6.2", "assets-webpack-plugin": "3.5.1", "awesome-typescript-loader": "3.4.1", + "codelyzer": "4.2.1", "copy-webpack-plugin": "4.4.1", "css-loader": "0.28.9", "exports-loader": "0.7.0", @@ -36,6 +37,7 @@ "extract-text-webpack-plugin": "~3.0.0", "file-loader": "1.1.9", "html-webpack-plugin": "2.30.1", + "husky": "0.14.3", "imports-loader": "0.8.0", "inline-manifest-webpack-plugin": "3.0.1", "istanbul-instrumenter-loader": "3.0.0", @@ -47,6 +49,7 @@ "karma-remap-coverage": "0.1.5", "karma-sourcemap-loader": "0.3.7", "karma-webpack": "2.0.9", + "lint-staged": "7.0.0", "node-sass": "4.7.2", "postcss-cssnext": "3.1.0", "postcss-import": "11.1.0", @@ -55,15 +58,19 @@ "postcss-simple-extend": "1.0.0", "postcss-url": "7.3.0", "preload-webpack-plugin": "2.2.0", + "prettier": "1.10.2", "raw-loader": "0.5.1", "sass-loader": "6.0.6", "script-ext-html-webpack-plugin": "1.8.8", "source-map-loader": "0.2.3", "string-replace-loader": "~1.3.0", "stylelint": "9.1.1", + "stylelint-config-prettier": "3.0.4", "stylelint-webpack-plugin": "0.10.3", "style-loader": "0.20.2", "to-string-loader": "1.1.5", + "tslint": "5.9.1", + "tslint-config-prettier": "1.8.0", "tslint-loader": "3.5.3", "uglifyjs-webpack-plugin": "1.2.0", "url-loader": "0.6.2", diff --git a/starter/.prettierignore b/starter/.prettierignore new file mode 100644 index 0000000000..4ab4dcd918 --- /dev/null +++ b/starter/.prettierignore @@ -0,0 +1,7 @@ +.git/ +.github/ +.idea/ +.vscode/ +dist/ +node_modules/ +package.json diff --git a/starter/.prettierrc.js b/starter/.prettierrc.js new file mode 100644 index 0000000000..7e1214d015 --- /dev/null +++ b/starter/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require("./node_modules/@nationalbankbelgium/stark-build/config/.prettierrc.js"); diff --git a/starter/.stylelintrc b/starter/.stylelintrc index 29f985762b..1031f5d2a9 100644 --- a/starter/.stylelintrc +++ b/starter/.stylelintrc @@ -1,433 +1,3 @@ { - "defaultSeverity": "error", - "rules": { - "color-hex-case": [ - "lower", - { - "message": "Lowercase letters are easier to distinguish from numbers." - } - ], - "color-hex-length": [ - "short", - { - "message": "Use short hex codes when possible to avoid unnecessary code." - } - ], - "color-named": [ - "never", - { - "message": "No named colors are allowed because of consistency. Always use hex or rgba." - } - ], - "font-family-name-quotes": [ - "always-where-required", - { - "message": "Quotes are required around font-family names when they are not valid CSS identifiers." - } - ], - "font-family-no-duplicate-names": [ - true, - { - "message": "Avoid duplicate information." - } - ], - "font-family-no-missing-generic-family-keyword": [ - true, - { - "message": "Always put at least one generic font family." - } - ], - "function-comma-space-after": [ - "always", - { - "message": "Always put a space after commas in functions to be consistent and improve readability." - } - ], - "function-comma-space-before": [ - "never", - { - "message": "Never put spaces before a comma to be consistent and improve readability." - } - ], - "function-max-empty-lines": [ - 0, - { - "message": "Avoid empty lines in functions to improve readability." - } - ], - "function-name-case": [ - "lower", - { - "message": "Function names should be in lowercase following the CSS specification." - } - ], - "number-leading-zero": [ - "never", - { - "message": "Should not contain leading zeros to avoid unnecessary code." - } - ], - "number-no-trailing-zeros": [ - true, - { - "message": "Should not contain trailing zeros to avoid unnecessary code." - } - ], - "string-quotes": [ - "double", - { - "message": "Always use double quotes for consistency." - } - ], - "length-zero-no-unit": [ - true, - { - "message": "Zero value should never have a unit to avoid unnecessary code." - } - ], - "unit-case": [ - "lower", - { - "message": "Units should always be lowercase for consistency. Lower case is more readable." - } - ], - "unit-no-unknown": true, - "value-keyword-case": [ - "lower", - { - "message": "Keyword values should always be lowercase for consistency. Lower case is more readable." - } - ], - "value-no-vendor-prefix": [ - true, - { - "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." - } - ], - "value-list-comma-newline-before": [ - "never-multi-line", - { - "message": "In value lists, there should never be a space or a newline between a comma and a previous value." - } - ], - "value-list-comma-space-after": [ - "always-single-line", - { - "message": "In single line value lists, there should always be a space after each comma for better readability." - } - ], - "value-list-comma-space-before": [ - "never", - { - "message": "In value lists, there should never be a space or a newline between a comma and a previous value." - } - ], - "value-list-max-empty-lines": [ - 0, - { - "message": "Value lists should never contain empty lines to make them better visible as a group." - } - ], - "property-case": [ - "lower", - { - "message": "Properties should always be lowercase for consistency. Lower case is more readable." - } - ], - "property-no-unknown": true, - "property-no-vendor-prefix": [ - true, - { - "message": "Don't use vendor prefixes: they are added when necessary by PostCSS." - } - ], - "keyframe-declaration-no-important": [ - true, - { - "message": "!important should only be used as a last resort and never in keyframe animations." - } - ], - "declaration-bang-space-after": [ - "never", - { - "message": "!important should never contain spaces." - } - ], - "declaration-bang-space-before": [ - "always", - { - "message": "!important should always be preceded by a space to improve readability." - } - ], - "declaration-colon-space-after": [ - "always", - { - "message": "Always add a space after a declaration colon to improve readability." - } - ], - "declaration-colon-space-before": [ - "never", - { - "message": "Never put a space between a declaration and the colon to avoid too much spaces." - } - ], - "declaration-block-no-duplicate-properties": [ - true, - { - "message": "All properties should only be defined once." - } - ], - "declaration-block-semicolon-newline-after": [ - "always", - { - "message": "Each property should be declared on a separate line to improve readability." - } - ], - "declaration-block-semicolon-newline-before": [ - "never-multi-line", - { - "message": "Never put a newline before a semicolon to avoid unnecessary whitespace." - } - ], - "declaration-block-semicolon-space-after": "always-single-line", - "declaration-block-semicolon-space-before": [ - "never", - { - "message": "Never put a space before a semicolon to avoid unnecessary whitespace." - } - ], - "declaration-block-trailing-semicolon": [ - "always", - { - "message": "The last declaration of a block should also include a semicolon to reduce errors when adding rules." - } - ], - "block-closing-brace-empty-line-before": [ - "never", - { - "message": "Never put a newline before a block closing bracket to avoid unnecessary whitespace." - } - ], - "block-closing-brace-newline-after": [ - "always", - { - "message": "Declaration blocks should always start on a new line to maximize readability." - } - ], - "block-closing-brace-newline-before": [ - "always-multi-line", - { - "message": "Always put a block closing bracket on a separate line for better readability." - } - ], - "block-opening-brace-newline-after": [ - "always-multi-line", - { - "message": "Always put a newline after a block opening bracket for better readability." - } - ], - "block-opening-brace-space-before": [ - "always", - { - "message": "Always put a space before a block opening bracket for better readability." - } - ], - "selector-attribute-brackets-space-inside": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-operator-space-after": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-operator-space-before": [ - "never", - { - "message": "Never put spaces inside selector attributes to avoid unnecessary whitespace." - } - ], - "selector-attribute-quotes": [ - "always", - { - "message": "Always put selector attribute values in quotes to be consistent and improve readability." - } - ], - "selector-combinator-space-after": [ - "always", - { - "message": "Always put spaces around selector combinators to improve readability." - } - ], - "selector-combinator-space-before": [ - "always", - { - "message": "Always put spaces around selector combinators to improve readability." - } - ], - "selector-descendant-combinator-no-non-space": [ - true, - { - "message": "Don't put tabs, newlines, nor multiple spaces between selector descendants to improve readability." - } - ], - "selector-max-id": [ - 0, - { - "message": "Never use #id as a selector: it is difficult to ensure ids are unique and because of their weight styles are difficult to override." - } - ], - "selector-pseudo-class-case": [ - "lower", - { - "message": "Always use lowercase for pseudo-class selectors for consistency and to improve readability." - } - ], - "selector-pseudo-class-no-unknown": true, - "selector-pseudo-element-case": [ - "lower", - { - "message": "Always use lowercase for pseudo-element selectors for consistency and to improve readability." - } - ], - "selector-pseudo-element-colon-notation": [ - "double", - { - "message": "Double colons (::) should be used instead of a single colon to distinguish pseudo-elements from pseudo-classes." - } - ], - "selector-pseudo-element-no-unknown": true, - "selector-type-case": [ - "lower", - { - "message": "Always use lowercase for tag name selectors for consistency and to improve readability." - } - ], - "selector-max-empty-lines": [ - 0, - { - "message": "Never put empty lines in selector blocks to improve readability and to avoid unnecessary whitespace." - } - ], - "selector-list-comma-newline-after": [ - "always", - { - "message": "Each selector has to be put on a separate line to improve readability." - } - ], - "selector-list-comma-newline-before": [ - "never-multi-line", - { - "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." - } - ], - "selector-list-comma-space-before": [ - "never", - { - "message": "Never put a newline or white space before a selector comma to avoid unnecessary whitespace." - } - ], - "media-feature-colon-space-after": [ - "always", - { - "message": "Always put a space after a media feature colon to improve readability." - } - ], - "media-feature-colon-space-before": [ - "never", - { - "message": "Never put a space before a media feature colon to avoid unnecessary whitespace." - } - ], - "media-feature-name-case": [ - "lower", - { - "message": "Always use lowercase for media feature names for consistency and to improve readability." - } - ], - "media-feature-name-no-unknown": true, - "media-feature-parentheses-space-inside": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "media-feature-range-operator-space-after": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "media-feature-range-operator-space-before": [ - "never", - { - "message": "Never put spaces inside media feature parentheses to avoid unnecessary whitespace." - } - ], - "at-rule-empty-line-before": [ - "always", - { - "ignore": [ - "after-comment", - "blockless-after-same-name-blockless" - ], - "ignoreAtRules": [ - "import" - ], - "message": "Always put an empty line before each @ rule, except after a comment or for @import." - } - ], - "at-rule-name-case": [ - "lower", - { - "message": "Always use lowercase for @ rule names for consistency and to improve readability." - } - ], - "at-rule-name-space-after": [ - "always", - { - "message": "Always put a space after @ rule names for consistency and to improve readability." - } - ], - "at-rule-no-unknown": true, - "at-rule-semicolon-newline-after": [ - "always", - { - "message": "Always put a newline after the ending @ rule semicolon to improve readability." - } - ], - "at-rule-semicolon-space-before": [ - "never", - { - "message": "Never put a newline after the ending @ rule semicolon to avoid unnecessary whitespace." - } - ], - "no-duplicate-at-import-rules": [ - true, - { - "message": "Avoid duplicate @import rule within the same stylesheet." - } - ], - "no-extra-semicolons": [ - true, - { - "message": "No extra semicolons: they don't make sense." - } - ], - "no-invalid-double-slash-comments": [ - true, - { - "message": "In CSS, double slashes do not indicate a single line comment. Use /* */ instead." - } - ], - "no-unknown-animations": [ - true, - { - "message": "Check your code. The animation name \"${animationName}\" is not defined." - } - ] - } + "extends": "./node_modules/@nationalbankbelgium/stark-build/config/stylelint.config.js" } diff --git a/starter/package.json b/starter/package.json index 29e6b094e5..7006c3c978 100644 --- a/starter/package.json +++ b/starter/package.json @@ -47,6 +47,8 @@ "postinstall": "npm run webdriver:update", "postversion": "git push && git push --tags", "preclean:install": "npm run clean", + "precommit": "lint-staged", + "prettier-check": "prettier **/*.{css,js,json,pcss,scss,ts} --write", "preversion": "npm test", "protractor": "protractor", "protractor:delay": "sleep 3 && npm run protractor", @@ -79,6 +81,12 @@ "webpack-dev-server": "node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js", "webpack": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js" }, + "lint-staged": { + "*.{css,js,json,pcss,scss,ts}": [ + "prettier --write", + "git add" + ] + }, "dependencies": { "@angular/animations": "5.2.6", "@angular/common": "5.2.6", @@ -110,7 +118,6 @@ "@types/node": "6.0.101", "@types/source-map": "0.5.2", "@types/uglify-js": "2.6.30", - "codelyzer": "4.1.0", "cross-env": "^5.0.0", "find-root": "^1.0.0", "gh-pages": "^1.0.0", @@ -122,7 +129,6 @@ "rimraf": "2.6.2", "ts-node": "3.3.0", "tslib": "1.8.1", - "tslint": "5.8.0", "typedoc": "0.9.0", "typescript": "2.6.2" }, diff --git a/starter/tslint.json b/starter/tslint.json index c6484074f9..67bfcf155c 100644 --- a/starter/tslint.json +++ b/starter/tslint.json @@ -1,43 +1,3 @@ { - "extends": ["tslint:recommended", "tslint-config-prettier"], - "rulesDirectory": ["node_modules/codelyzer"], - "rules": { - // Custom - "interface-name": [false, "always-prefix"], - // Angular 2 - "component-class-suffix": true, - // "component-selector": [true, "element", "my", "kebab-case"], - "directive-class-suffix": true, - // "directive-selector": [true, "attribute", "my", "camelCase"], - "no-attribute-parameter-decorator": true, - "no-forward-ref": true, - "no-input-rename": true, - "no-output-rename": true, - "only-arrow-functions": false, - "pipe-naming": [true, "camelCase", "my"], - "use-host-property-decorator": true, - "use-input-property-decorator": true, - "use-life-cycle-interface": true, - "use-output-property-decorator": true, - "use-pipe-transform-interface": true, - // General - "no-console": [true, "time", "timeEnd", "trace"], - "no-string-literal": false, - "no-use-before-declare": true, - "object-literal-sort-keys": false, - "ordered-imports": false, - "variable-name": [true, "allow-leading-underscore", "allow-pascal-case", "ban-keywords", "check-format"] - } - //These rules are handled by Prettier - // "trailing-comma": [false, {"multiline": "always", "singleline": "never"}], - // "import-destructuring-spacing": true, - // "max-line-length": [ - // true, - // 100 - // ], - // "quotemark": [ - // true, - // "single", - // "avoid-escape" - // ], + "extends": ["./node_modules/@nationalbankbelgium/stark-build/config/tslint.json"] } diff --git a/tslint.json b/tslint.json index a9aa968818..19a58545be 100644 --- a/tslint.json +++ b/tslint.json @@ -1,321 +1,3 @@ { - "extends": ["tslint:latest", "tslint-config-prettier"], - "defaultSeverity": "error", - "rules": { - "member-access": [true, "check-accessor", "check-constructor", "check-parameter-property"], - "member-ordering": [ - false, - { - "order": "fields-first" - } - ], - "no-any": false, - "no-empty-interface": false, - "no-inferrable-types": false, - "no-internal-module": true, - "no-namespace": [true, "allow-declarations"], - "no-reference": true, - "no-var-requires": false, - "typedef": [ - true, - "call-signature", - // "arrow-call-signature", - "parameter", - "arrow-parameter", - "property-declaration", - "variable-declaration", - "member-variable-declaration", - "object-destructuring", - "array-destructuring" - ], - "typedef-whitespace": [ - false, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "unified-signatures": true, - "ban": [ - true, - "window", - "eval", - { "name": ["angular", "bind"], "message": "Use Function bind() method" }, - { - "name": ["angular", "copy"], - "message": "Use Lodash cloneDeep() or Object/Array spread syntax" - }, - { - "name": ["angular", "equals"], - "message": "Use strict equality comparison (===)" - }, - { - "name": ["angular", "extend"], - "message": "Use Lodash merge() or Object spread syntax" - }, - { - "name": ["angular", "forEach"], - "message": "Use for...of loop, for...in loop or Array forEach()" - }, - { "name": ["angular", "fromJson"], "message": "Use JSON.parse()" }, - { - "name": ["angular", "isArray"], - "message": "Use Array.isArray() function" - }, - { - "name": ["angular", "isDate"], - "message": "Use moment.isDate() function" - }, - { - "name": ["angular", "isDefined"], - "message": "Use typeof operator (type guard)" - }, - { - "name": ["angular", "isFunction"], - "message": "Use typeof operator (type guard) or Lodash isFunction()" - }, - { - "name": ["angular", "isNumber"], - "message": "Use typeof operator (type guard) or Lodash isNumber()" - }, - { - "name": ["angular", "isString"], - "message": "Use typeof operator (type guard) or Lodash isString()" - }, - { - "name": ["angular", "isUndefined"], - "message": "Use typeof operator (type guard) or Lodash isUndefined()" - }, - { - "name": ["angular", "merge"], - "message": "Use Lodash merge() or cloneDeep()" - }, - { "name": ["angular", "noop"], "message": "Use Lodash noop()" }, - { "name": ["angular", "toJson"], "message": "Use JSON.stringify()" } - ], - "curly": true, - "forin": true, - "label-position": true, - "no-arg": true, - "no-bitwise": true, - "no-conditional-assignment": true, - "no-console": [false, "debug", "info", "time", "timeEnd", "trace"], - "no-construct": true, - "no-debugger": true, - "no-duplicate-variable": true, - "no-empty": [true, "allow-empty-catch"], - "no-eval": true, - "no-implicit-dependencies": false, - "no-invalid-template-strings": true, - "no-invalid-this": true, - "no-null-keyword": true, - "no-object-literal-type-assertion": true, - "no-return-await": true, - "no-shadowed-variable": true, - "no-sparse-arrays": true, - "no-string-literal": false, - "no-string-throw": false, - "no-submodule-imports": [false, "@nationalbankbelgium", "rxjs", "lodash", "core-js", "valdr", "angular-material"], - "no-switch-case-fall-through": true, - "no-this-assignment": false, - "no-unnecessary-class": ["allow-static-only"], - "no-unsafe-finally": true, - "no-unused-expression": true, - "no-var-keyword": true, - "prefer-conditional-expression": false, - "prefer-object-spread": true, - "prefer-template": false, - "radix": true, - "switch-default": true, - "triple-equals": true, - "typeof-compare": true, - "use-isnan": true, - "cyclomatic-complexity": [true, 20], - "no-default-export": true, - "no-duplicate-imports": true, - "no-mergeable-namespace": true, - "no-require-imports": false, - "object-literal-sort-keys": false, - "align": [false, "arguments", "statements", "parameters", "members", "elements"], - "callable-types": true, - "class-name": true, - "comment-format": [false, "check-space"], - "encoding": false, - "interface-name": [false, "never-prefix"], - "interface-over-type-literal": true, - "jsdoc-format": false, - "no-angle-bracket-type-assertion": false, - "no-parameter-properties": true, - "no-redundant-jsdoc": false, - "no-reference-import": true, - "no-unnecessary-callback-wrapper": false, - "object-literal-shorthand": false, - "one-variable-per-declaration": true, - "switch-final-break": false, - "type-literal-delimiter": true, - "variable-name": [true, "check-format", "allow-leading-underscore", "allow-trailing-underscore", "ban-keywords"], - "whitespace": [ - false, - "check-branch", - "check-decl", - "check-operator", - "check-module", - "check-separator", - "check-rest-spread", - "check-type", - "check-typecast", - "check-type-operator", - "check-pre-block" - ], - "prefer-const": [ - true, - { - "destructuring": "all" - } - ], - "no-magic-numbers": false, - "import-blacklist": true, - "ordered-imports": false, - "max-classes-per-file": false, // [true, 1], - "prefer-for-of": true, - "array-type": false, // [true, "array"] - "arrow-return-shorthand": true, - "binary-expression-operand-order": false, - "no-unnecessary-initializer": true, - "no-misused-new": true, - "prefer-method-signature": false, - "prefer-switch": [ - true, - { - "min-cases": 3 - } - ], - "prefer-function-over-method": false, - "no-import-side-effect": [ - true, - { - "ignore-module": "(rxjs|reflect-metadata|core-js|ngrx-store|angular|polyfills|vendor|typings|\\.css|\\.pcss)" - } - ], - "no-non-null-assertion": true, - "no-parameter-reassignment": false, - "adjacent-overload-signatures": true, - "ban-comma-operator": false, - "ban-types": false, - "no-duplicate-super": true, - "no-duplicate-switch-case": true, - "newline-before-return": false - } - - //These rules require type info to run - // "strict-boolean-expressions": true, - // "promise-function-async": true, - // "no-inferred-empty-object-type": true, - // "no-void-expression": true, - // "completed-docs": true, - // "no-unbound-method": true, - // "no-boolean-literal-compare": true, - // "no-unsafe-any": true, - // "no-unnecessary-qualifier": true, - // "no-unnecessary-type-assertion": true, - // "no-use-before-declare": true, - // "await-promise": true, - // "no-floating-promises": true, - // "strict-type-predicates": true, - // "match-default-export-name": true, - // "return-undefined": true, - // "deprecation": true, - // "use-default-type-parameter": true, - // - //These rules are handled by Prettier - // "eofline": true, - // "import-spacing": true, - // "indent": [ - // false, - // "tabs", - // 2 - // ], - // "max-line-length": [ - // true, - // 140 - // ], - // "no-trailing-whitespace": false, - // "one-line": [ - // true, - // "check-catch", - // "check-finally", - // "check-else", - // "check-open-brace", - // "check-whitespace" - // ], - // "quotemark": [ - // true, - // "double", - // "avoid-escape" - // ], - // "semicolon": [ - // true, - // "always" - // ], - //Cases searched manually - // "trailing-comma": [ - // false, - // { - // "multiline": { - // "objects": "always", - // "arrays": "always", - // "functions": "always", - // "imports": "always", - // "exports": "always", - // "typeLiterals": "ignore" - // }, - // "singleline": { - // "objects": "never", - // "arrays": "never", - // "functions": "never", - // "imports": "never", - // "exports": "never", - // "typeLiterals": "ignore" - // }, - // "esSpecCompliant": true - // } - // ], - // "space-before-function-paren": [ - // true, - // { - // "anonymous": "always", - // "named": "never", - // "asyncArrow": "never", - // "method": "never", - // "constructor": "never" - // } - // ], - // "space-within-parens": 0, - // "no-irregular-whitespace": true, - // "no-consecutive-blank-lines": [ - // true, - // 1 - // ], - //Signaled by tslint-check script - // "arrow-parens": true, - // "linebreak-style": [ - // true, - // "LF" - // ], - // "new-parens": true, - // "number-literal-format": true, - // "object-literal-key-quotes": [ - // true, - // "as-needed" - // ], + "extends": ["./packages/stark-build/config/tslint.json"] }