Skip to content

Commit

Permalink
feat: show eslint warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
varl committed Mar 12, 2021
1 parent 9c25383 commit fb4972a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
15 changes: 8 additions & 7 deletions config/js/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const SEVERITY = 2

module.exports = {
extends: [
'eslint:recommended',
Expand All @@ -8,6 +6,9 @@ module.exports = {
'plugin:import/warnings',
],

// unignore implicit rules about what types of files can be linted
ignorePatterns: ['!.*'],

plugins: ['prettier'],

env: {
Expand All @@ -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: {
Expand Down
25 changes: 24 additions & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
1 change: 0 additions & 1 deletion src/tools/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] : []),
Expand Down

0 comments on commit fb4972a

Please sign in to comment.