From fb4972af6ae017c6935861034aa7f098c9ca336c Mon Sep 17 00:00:00 2001 From: Viktor Varland Date: Wed, 10 Mar 2021 19:23:24 +0100 Subject: [PATCH] feat: show eslint warnings This removes the `--quiet` flag from the ESLint invocation, and fixes the broken output where ESLint complains about us trying to lint dot-files and folders by un-ignoring their built-in ignore filters. We agree with ignoring node_modules in terms of linting however, so that is left in place. --- config/js/eslint.config.js | 15 ++++++++------- docs/faq.md | 25 ++++++++++++++++++++++++- src/tools/eslint.js | 1 - 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/config/js/eslint.config.js b/config/js/eslint.config.js index bf21735b..eb9de21b 100644 --- a/config/js/eslint.config.js +++ b/config/js/eslint.config.js @@ -1,5 +1,3 @@ -const SEVERITY = 2 - module.exports = { extends: [ 'eslint:recommended', @@ -8,6 +6,9 @@ module.exports = { 'plugin:import/warnings', ], + // unignore implicit rules about what types of files can be linted + ignorePatterns: ['!.*'], + plugins: ['prettier'], env: { @@ -28,22 +29,22 @@ module.exports = { rules: { 'max-params': [ - SEVERITY, + 'error', { max: 3, }, ], 'prefer-const': [ - SEVERITY, + 'error', { destructuring: 'any', ignoreReadBeforeAssign: false, }, ], - 'no-mixed-spaces-and-tabs': [SEVERITY], - 'prettier/prettier': [SEVERITY], + 'no-mixed-spaces-and-tabs': ['error'], + 'prettier/prettier': ['error'], 'import/order': [ - SEVERITY, + 'error', { 'newlines-between': 'never', alphabetize: { diff --git a/docs/faq.md b/docs/faq.md index af77f5df..27c5495b 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -2,7 +2,7 @@ Some wisdom from Go: -> Gofmt's style is no one's favorite, yet gofmt is everyone's favorite. +> `gofmt`'s style is no one's favorite, yet `gofmt` is everyone's favorite. # I'm getting husky errors @@ -16,3 +16,26 @@ You can reinstall it using 'npm install husky --save-dev' or delete this hook You can remove the husky hooks from `.git/hooks` and opt in to use the hooks provided here with e.g. `d2-style install git-hooks/all`. + +Ensure that your node and git versions satisfy the above requirements. +You can check this by running `git --version` and `node --version` from +your terminal. + +# What does an Error and Warnings mean? + +`d2-style` is strict by default, as it tries to guard against known lint +from entering the codebase. If the lint is denied early, it is easier, +and faster, to fix it. + +We set most our style rules as error to serve this purpose. This works +best when `d2-style` is added to a project that doesn't have a lot of +code yet. + +It is also not fun when `d2-style` decides to adopt new rules as errors. +That means by simply updating `d2-style` the codebase can be in need of +significant clean-ups. This is problematic because it can slow adoption +of new versions of the code style, and it can hold back adoption of new +and better code style rules. + +To allow for gradual adoption of rules, warnings can be used before +upgrading them to errors. diff --git a/src/tools/eslint.js b/src/tools/eslint.js index 0e871865..fda1e6c0 100644 --- a/src/tools/eslint.js +++ b/src/tools/eslint.js @@ -9,7 +9,6 @@ exports.eslint = ({ files = [], apply = false, config }) => { '--no-color', '--report-unused-disable-directives', '--ignore', - '--quiet', '--format=unix', `--resolve-plugins-relative-to=${PACKAGE_ROOT}`, ...(ignoreFile ? ['--ignore-path', ignoreFile] : []),