Coder Social home page Coder Social logo

ryanzim / eslint-config-problems Goto Github PK

View Code? Open in Web Editor NEW
67.0 3.0 3.0 38 KB

An eslint config that catches problems in your code, without checking style. For use with prettier.

License: ISC License

JavaScript 100.00%
eslint prettier linter-config eslint-config

eslint-config-problems's Introduction

eslint-config-problems

eslint-config-problems is an ESLint config that doesn't regulate your code style. It only catches actual problems with your code.

It's designed for use with Prettier, the opinionated code formatter; but you could also use this as a solid base config to add stylistic rules on top of.

Contents

Rules

Rules were chosen based on the following criteria:

  • No stylistic rules; nothing that Prettier can fix
  • Prevent guaranteed runtime errors (i.e. no undefined variables)
  • Disallow "evil" things like eval
  • Disallow archaic language features like with
  • Disallow obvious bad practices like new Number(13)
  • Force usage of ES2015+ features supported by Node.js v10+
  • Point out places the code could be made shorter. For example:
    if (someCondition) return someValue;
    else {
      // Do something else
    }
    The else block is unneeded, since the if block contains a return statement. eslint-config-problems will point this out to you (or auto-fix with the --fix option).

eslint-config-problems also sets ecmaVersion: 2020 in the parserOptions, so that ESLint can parse modern code (including BigInt) with no additional setup.

I disagree with rule X; you missed rule Y

If you disagree; feel free to open an issue. I'm open to changing rules if you have a good reason.

If I missed a rule that prevents an actual problem or is otherwise in keeping with the general guidelines above, please open an issue as well; I just might add it.

Installation & Usage

eslint-config-problems doesn't set any environments by default, other than the es6 environment. So you'll have to manually set your environment in your ESLint config. Here's a list of environments.

If you're using ES Modules, you will need to set sourceType: module in the parserOptions, like this:

parserOptions:
  sourceType: module

Just ESLint

npm install -D eslint eslint-config-problems

In your eslintrc.yaml:

extends: 'problems'
env:
  # Set your environments here; for example:
  node: true
npm install -D eslint prettier eslint-config-problems eslint-plugin-prettier

In your eslintrc.yaml:

extends: 'problems'
env:
  # Set your environments here; for example:
  node: true
plugins:
  - prettier
rules:
  - prettier/prettier: error

License

ISC

eslint-config-problems's People

Contributors

renovate[bot] avatar ryanzim avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

eslint-config-problems's Issues

Missing node8 subconfig

I installed the new 3.0 version and try to run eslint. It says that it cannot find module eslint-config-problems/node8 when using the node10 subconfig.

The node10.js file references the removed node8 subconfig:

extends: 'problems/node8',

How should I solve this?

Dependency Dashboard

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

Open

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

Detected dependencies

npm
package.json
  • doctoc ^2.0.0
  • eslint ~8.38.0
  • lodash.defaultsdeep ^4.6.0
  • prettier ^3.0.0
  • eslint ^8.27.0

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

Rule: strict

Hi,

I see that the rule strict is enabled by your config. I find that strange, as writing "use strict" in all my source files when writing a module in 2019 is unnecessary, especially that Module code is always strict mode code.

10.2.1 Strict Mode Code
[...]

  • Module code is always strict mode code.

[...]

Shouldn't this rule be opt-in when writing code for the browser instead of opt-out for node.js? I mean, most of the time we use some kind of bundler for browser code which puts the "use strict" there anyway.

`async`/`await` support?

I love the idea behind this config, but it's complaining about async / await in my Node 8 code.

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.