netlify / eslint-config-node Goto Github PK
View Code? Open in Web Editor NEWESLint, Prettier and Editorconfig shared by Netlify's Node.js projects
License: MIT License
ESLint, Prettier and Editorconfig shared by Netlify's Node.js projects
License: MIT License
Instead of using the list of recommended rules from eslint-plugin-unicorn
, we should manually enable each rule we want to use.
Like this, new versions of ESLint plugins do not add rules without us explicitly enabling them.
While I agree with this rule in principle, I find myself fighting with it a lot. It's particularly problematic in files where we pass lots of parameters around (see https://github.com/netlify/build/blob/master/.eslintrc.js#L38-L46).
In this particular case, I like how explicit we are about the parameters we receive and pass to each function. By doing this, we can be conservative about what we expose to other functions downstream. But this makes the code more verbose, which conflicts with this rule.
Any thoughts?
Which problem is this feature request solving?
See netlify/build@ed3775a#diff-21d7febb920de5511d3fd774505b2df8d3c295ff0b2ce579333c0b1c73cf0c80
Similar to the run-e
script it would be useful to add run-local
and possibly a run-ci
script to only run commands locally/on CI
Describe the solution you'd like
Export a run-local
scripts as a bin
field so consumers can run a command only locally and not on CI.
Describe alternatives you've considered
Duplicating that code across repos
Can you submit a pull request?
Yes
Additional notes
Use https://github.com/watson/is-ci instead of process.env.CI
I find myself skipping this rule whenever I need to sort an array. Take the following example:
const applyConfigToFunction = ({ config, func }) => {
// It's safe to mutate the array because it's local to this function.
// eslint-disable-next-line fp/no-mutating-methods
const matches = Object.keys(config)
.filter((expression) => minimatch(func.name, expression))
.map((expression) => {
const starCount = [...expression].filter((char) => char === '*').length
return {
expression,
weight: expression.length - starCount - (starCount ? 1 : 0),
}
})
.sort((fA, fB) => fA.weight - fB.weight)
const functionConfig = matches.reduce((result, { expression }) => mergeConfigObjects(result, config[expression]), {})
return {
[func.name]: functionConfig,
}
}
In my view, this example adheres to the functional programming paradigm. The usage of sort
does not cause any side effects. More importantly, there are no obvious alternatives to it.
What do you think?
I want to discuss this rule and why we are forbidding the use of for-of
or for
loops.
https://github.com/jfmengels/eslint-plugin-fp/blob/master/docs/rules/no-loops.md
In general if you need something performant a for loop is unbeatable on large scale
like
for (let i = 0, max = hugeSet.length(); i < max; i ++) {
...
}
a different example often you want to iterate over an iterate-able with entries in a sync manor where some async code is awaited:
for (const entry of entries) {
await doSomeAsync(entry)
console.log('done for entry')
}
IMO these are valid examples to use a for
or forof
and we should not forbid them.
cc @eduardoboucas @ehmicky @netlify-team-account-1 @ascorbic @erezrokah
When #368 was merged, I assume that removed the need to have specific config for React or Vanilla JS projects? Or is there some additional config that is still needed for projects of these types?
The following ruleset which is new causing issues:
node/no-missing-require
node/no-missing-import
import/no-unresolved
In general they seem to be redundant (the ones from the node package with the ones from the import package)
This rule was causing our CI to fail on the publish of a release candidate because it requires installing dependencies. https://netlify.slack.com/archives/CBC2U9MMG/p1642520718015700
https://github.com/netlify/cli/runs/4855518297?check_suite_focus=true
This is not the major problem despite the fact that it increases our CI usage without the need to.
In my opinion which drives me crazy currently is if you work on multiple issues in parallel that have different additions on dependencies you cannot just switch to the other branch do a small typo fix and push.
(As on push the lint rule is run and complains about a non existing dependency)
So I have to run install (as I don't want to bypass it by running with --no-verify
)
This is not a huge issue if you don't add or remove dependencies but if you do it can get quite frustrating.
This is an issue generated by (for-internal-use-only)github-tools
This repository has exceeded the development grace period, and the repo owner must decide if branch protections should be enforced.
If this repository houses code used in production in any capacity, branch protections must be enforced. Read (for-internal-use-only)here for more details
I am proposing that this config is reduced to a more minimal and less opinionated set of rules. A lot of repos have been disabling many of these rules because they can be quite disruptive, and build
has stopped using them entirely. Instead of more repos disabling more of these rules I propose we cut it down to a much more minimal set of rules:
For the Unicorn rules, if we go ahead I will do a list and we can discuss the choices.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
In compute we have some styling rules that are currently not enforced, but somewhat manually requested in PRs.
These two rules are:
something
+
return x
var u = 3
const x = 1
let y = 2
+
something
In zip-it-and-ship-it
we enabled the rule padding-line-between-statements
with the following config
'padding-line-between-statements': [
'error',
// Require newline before return
{ blankLine: 'always', prev: '*', next: 'return' },
// Require newline after a batch of variable declarations
{ blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
{ blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
],
and this ensures that these exact two behaviors mentioned above are enforced.
Is this something that other teams are doing as well?
Should we enable this globally in this eslint config for all nodejs projects?
Are there any reasons against doing this?
I think if we can agree on this, this is one less thing to worry about when reviewing or writing nodejs code.
I brought this up in the dev tooling guild before and now here as a concrete issue.
cc @Skn0tt @eduardoboucas @ascorbic @khendrikse @lukasholzer @netlify/netlify-dev
We should consider adding a shared configuration for React/Browser applications.
Those might have a set of rules completely different than the ones this library provides, so we can also decide not to have them as a part of this library.
However, having everything at the same place can help with maintenance.
Should we start we something simple like:
...overrides,
{
files: ['*.jsx'],
extends: ['eslint:recommended', 'plugin:react/recommended'],
},
and see how it goes?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are currently rate-limited. Click on a checkbox below to force their creation now.
@typescript-eslint/eslint-plugin
, @typescript-eslint/parser
)These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
@babel/core
, @babel/eslint-parser
)@commitlint/cli
, @commitlint/config-conventional
).github/workflows/fossa.yml
actions/checkout v4
.github/workflows/labeler.yml
netlify/pr-labeler-action v1.1.0
.github/workflows/pre-release.yml
actions/checkout v4
actions/setup-node v4
.github/workflows/release-please.yml
navikt/github-app-token-generator a8ae52448279d468cfbca5cd899f2457f0b1f643
GoogleCloudPlatform/release-please-action v3
actions/checkout v4
actions/setup-node v4
.github/workflows/workflow.yml
actions/checkout v4
actions/setup-node v4
package.json
@babel/core ^7.13.8
@babel/eslint-parser ^7.13.8
@commitlint/cli ^17.0.0
@commitlint/config-conventional ^17.0.0
@typescript-eslint/eslint-plugin ^5.0.0
@typescript-eslint/parser ^5.0.0
cross-env ^7.0.2
eslint ^8.0.0
eslint-config-prettier ^8.0.0
eslint-config-standard ^17.0.0
eslint-formatter-codeframe ^7.32.1
eslint-import-resolver-node ^0.3.4
eslint-import-resolver-typescript ^3.0.0
eslint-plugin-ava ^13.0.0
eslint-plugin-cypress ^2.12.1
eslint-plugin-eslint-comments ^3.2.0
eslint-plugin-fp ^2.3.0
eslint-plugin-html ^7.0.0
eslint-plugin-import ^2.25.1
eslint-plugin-markdown ^3.0.0
eslint-plugin-n ^15.2.4
eslint-plugin-promise ^6.0.0
eslint-plugin-react ^7.21.5
eslint-plugin-unicorn ^43.0.0
eslint-plugin-you-dont-need-lodash-underscore ^6.10.0
execa ^6.0.0
husky ^8.0.0
is-ci ^3.0.0
npm-run-all2 ^5.0.0
prettier ^2.1.2
statuses ^2.0.1
ava ^4.0.0
node >=16.0.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.