Giter VIP home page Giter VIP logo

eslint-config-node's People

Contributors

ascorbic avatar danez avatar dustincrogers avatar eduardoboucas avatar ehmicky avatar erezrokah avatar github-actions[bot] avatar netlify-bot avatar netlify-team-account-1 avatar renovate-bot avatar renovate[bot] avatar skn0tt avatar token-generator-app[bot] avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

eslint-config-node's Issues

Discussing rule: max-lines-per-function

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?

Feature: add `run_local` script

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

Discussing rule: fp/no-mutating-methods

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?

Discussion eslint rule `fp/no-loops`

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

Update README with latest usage instructions

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?

Discussion `node/no-missing-import`, `node/no-missing-require`,`import/no-unresolved`

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.

CleanShot 2022-01-19 at 10 58 40@2x

[security] Enforce Branch Protections

This is an issue generated by (for-internal-use-only)github-tools

Description

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

What do I need to do?

  • You can control whether or not branch protections are enforced by exclusively creating either of the labels:
    'enforce-branch-protections: true' or 'enforce-branch-protections: false'
  • If there is no branch protection control label, this issue will be recreated.
  • Once you have created either label, you can close this issue.
  • If you have issues or questions, please reach out to #internal-security-n-compliance on slack.

Discussion: remove a lot of opinionated rules

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:

  1. remove fp, standard, you-dont-need-lodash-underscore and ava plugins. fp is too opinionated. standard doesn't have much point with prettier. We don't need eslint to tell us not to use lodash. Ava is only used on certain repos, which can add it as needed.
  2. Change most of the other plugins to use their "recommmended" rule sets
  3. enable a very limited set of unicorn rules. I suggets that these be limited to: ones that catch actual mistakes, and ones that suggest easier ways to do things that people might not know about.

For the Unicorn rules, if we go ahead I will do a list and we can discuss the choices.

Action Required: Fix Renovate Configuration

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.

Discussion eslint rule `padding-line-between-statements`

In compute we have some styling rules that are currently not enforced, but somewhat manually requested in PRs.
These two rules are:

  1. Add an empty line before a return statement:
 something
+
 return x
  1. Add an empty line after a variable declaration, unless next statement is also a variable declaration:
 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

Feature: Browser/React specific rules

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?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • fix(deps): update dependency eslint-plugin-react to v7.34.3
  • fix(deps): update dependency eslint-plugin-promise to v6.2.0
  • fix(deps): update dependency eslint-plugin-markdown to v5
  • fix(deps): update dependency eslint-plugin-n to v17
  • fix(deps): update dependency eslint-plugin-unicorn to v54
  • fix(deps): update dependency execa to v9
  • fix(deps): update dependency husky to v9
  • fix(deps): update dependency npm-run-all2 to v6
  • fix(deps): update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • chore(deps): lock file maintenance
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.