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 254342f commit ebceb04
Show file tree
Hide file tree
Showing 3 changed files with 37 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
30 changes: 29 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 @@ -14,3 +14,31 @@ You can reinstall it using 'npm install husky --save-dev' or delete this hook
```

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 to `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 not fun to add `d2-style` when the codebase has grown and
accumulated what is considered lint. Everything as errors means that it
will take real effort to de-lint the codebase.

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.

So `d2-style` operates with two levels: `--strict` and `--no-strict`.

In both modes, errors are considered problems significant enough that
they cannot be allowed into the code base.

In strict mode, warnings are NOT allowed into the code base.

In the non-strict mode, warnings are allowed into the code base and can
be used as an interim solution to allow for planned de-linting.
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 ebceb04

Please sign in to comment.