Détail du package

@scottnonnenberg/eslint-config-thehelp

scottnonnenberg56MIT0.9.0

The way I write javascript.

eslint, eslintconfig, thehelp, functional

readme

@scottnonnenberg/eslint-config-thehelp

Because the tools can help us write better code. Use this package directly, or fork it and make it your own! :0)

Blog post announcing this project: https://blog.scottnonnenberg.com/eslint-part-1-exploration/

continous integration npm version license

Quickstart

npm install @scottnonnenberg/eslint-config-thehelp --save-dev

In your ESLint config (I prever .eslintrc.js), extend this project's default configuration:

module.exports = {
  extends: [
    '@scottnonnenberg/thehelp',
  ],
};

As always, you can override any settings provided in this package in your configuration's rules object.

Configurations in this project

  1. @scottnonnenberg/thehelp/core - Basic good javascript practices. Node.js and CommonJS. Note: does not prevent the use of ES2015 constructs.
  2. @scottnonnenberg/thehelp/es2015 - Preferring ES2015 constructs over ES5 constructs. import/export instead of module.exports. Will run on on Node.js 6.x without a separate compile step if export/import are not used (turn off import/no-commonjs). Otherwise Babel is required. You'll definitely need Babel for the browser.
  3. @scottnonnenberg/thehelp/functional - Eliminating mutation of data and all loops, in favor of functional design.
  4. @scottnonnenberg/thehelp (default) - the previous three combined into one configuration. Suitable for any node module or server project.
  5. @scottnonnenberg/thehelp/react - rules for JSX and React component structure, as well as accessibility.
  6. @scottnonnenberg/thehelp/scripts - a looser configuration appropriate for your project's scripts/ directory. For example, allows use of devDependencies.
  7. @scottnonnenberg/thehelp/test - a configuration appropriate for your projects test/ directory, bringing in two new plugins, the mocha env, and relaxing a few rules. For example, turns off immutable/no-let to allow test setup in before/beforeEach.

Key configuration

To allow eslint-plugin-import to do its magic, you will need to tell it where to find your modules. I use this in my project's root directory:

{
  settings: {
    'import/resolver': {
      node: {
        paths: [__dirname],
      },
    },
  },
}

If using react config, you can get more precise deprecation warnings by setting your React version:

{
  react: {
    version: '15.0',
  },
}

Compatibility

This project is compatible with npm version 3 only. The goal is to make this a one-stop install for eslint and its plugins, but plugin name resolution for eslint is hardcoded to the top-level. Installing this with npm 3.x will ensure that. npm version 2, however, puts this project's dependences underneath it in the directory streucture, making them invisible to the larger project.

This may change if there is progress on this issue: https://github.com/eslint/eslint/issues/3458

Note: if you have ESLint or any ESLint plugins installed yourself, they will supercede the plugins installed with this project. Check this if you're getting errors, like 'unknown rule.'

My principles for rules

I want rules to specify the 98% case. /* eslint-disable [rules] */ and // eslint-disable-line will cover the rest. I can periodically search for those exceptions and reconsider their justification.

Next, I believe strongly that all style mandates for a project should have automated tools which verify them. I’ve spent way, way too long talking about style in pull request reviews. Yes, some things can't be verified very easily in an automated fashion. Get creative to implement new verification schemes (write an ESLint plugin!). If you still can't do that, then make as few as possible of these kinds of manual requirements.

Details for this project:

  • All rules from all plugins must be included. This is easy with npm scripts using eslint-find-rules.
  • Rules are in alphabetical order: first core eslint rules, then plugins sorted by name.
  • Always use 'error' or 'off' instead of 0 and 2. Numbers are for real config values.
  • No warnings. either disallow it completely, or don't worry about it.
  • All 'off' rules must have a reason mentioned.
  • Configuration should be nothing but 'error' if it matches the default settings for the rule.

Other notes:

  • consistent-return rule is incompatible with @scottnonnenberg/notate and thehelp-core's breadcrumbs
  • I've left thehelp/absolute-or-current-dir for you to configure; it is off by default but I do recommend it.

Contributing

This project uses standard-version to release new versions, automatically updating the version number and changelog based on commit messages in standard format. husky and validate-commit-msg are used to ensure all commit messages match the expected format (see package.json for the configuration details).

It takes some getting used to, but this configuration is absolutely worthwhile. A changelog is way easier to understand than the chaos of a raw commit stream, especially with standard-version providing direct links to bugs, commits and commit ranges.

TODO:

License

(The MIT license)

Copyright (c) 2016 Scott Nonnenberg scott@nonnenberg.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.9.0 (2021-11-26)

⚠ BREAKING CHANGES

  • typescript: Remove es2015 sub-configuration, remove functional from core configuration, enable reportUnusedDisableDirectives, add 'es2020' to env.
  • deps: Needed dependencies are no longer installed automatically with this package. This package expresses its needs with peerDependencies now.

Features

  • deps: Move dependencies to peerDependencies (29b2dec)
  • deps: Use peerDependenciesMeta to mark all non-core deps optional (aa7b07e)
  • prettier: Two new configs - prettier and prettierReact (2b4d7db)
  • rules: A few changes to rules; match export rule now enabled (656c8d8)
  • rules: Add missing rules from all plugins, fix new lint errors (af4567c)
  • rules: New scripts to find deprecated rules (7503d14)
  • rules: Remove deprecated rules (b9a385a)
  • rules: Update to latest @scottnonnenberg/eslint-plugin-thehelp (2f58adc)
  • typescript: A new set of typescript-specific rules (fc3959e)

Bug Fixes

  • deps: Fix peerDependencies - need to add stuff to devDependencies (a16dc01)
  • rules: Fix references to rules from my package (ede36f0)

0.8.0 (2017-02-17)

Features

  • scripts: Allow the usage of process.env with scripts preset (e27c2f2)

0.7.0 (2017-01-20)

Features

  • core: Allow ++ and -- inside loops. Fixes #3 (248d13d)

0.6.1 (2016-06-13)

Bug Fixes

  • default: Properly reference new scoped name in default config (4673cba)

0.6.0 (2016-06-12)

Bug Fixes

  • eslint-find-rules: update to version that handles scoped plugins (d9d6d1e)

Features

  • license: Officially open-source this project under MIT license (13a12fd)
  • package.json: Update keywords, author, repository (26968ff)

0.5.0 (2016-06-07)

  • Add eslint-plugin-filenames to project, turn on match-regex for snake_case.js filenames, keep the other two rules off for now.

0.4.2 (2016-06-03)

  • Turn off enforceConst for no-magic-numbers rule in core config, re-enable in es2015 config

0.4.1 (2016-06-03)

  • update to thehelp 0.3.2. It properly handles { object: 'this' } exceptions now.

0.4.0 (2016-06-02)

  • thehelp/no-mutation and thehelp/no-array-mutation both added for functional configuration, and immutable/no-mutation is turned off
  • thehelp/absolute-or-current-dir is off by default
  • add thehelp plugin, with three new rules
  • update to eslint 2.11.1, re-enable max-statements-per-line
  • remove React version setting from react configuration
  • update to jsx-a11y 1.2.3

0.3.2 (2016-05-28)

0.3.1 (2016-05-28)

0.3.0 (2016-05-28)

  • removed babel-eslint from project, es2015 config now configures default parser for ES7 language features. The only thing missing with this setup is static propTypes = {} in class-based React components.
  • no-empty-function turned off for core, same configuration moved to es2015. With no arrow function release valve, this rule was too much.
  • no-undefined turned off for tests config. Sometimes you gotta use undefined in your tests!
  • update to eslint 2.11.0, turned on three new rules: no-prototype-builtins, no-useless-rename, unicode-bom
  • update to jsx-a11y 1.1.2
  • update to import 1.8.1

0.2.0 (2016-05-25)

  • combined no longer done manually, now rely on eslint to combine for us. lodash is now just a dev dependency.
  • trimmed down npm package

0.1.0 (2016-05-25)

  • First take as a separate project: combined, core, es2015, functional, react, scripts, and tests configs available
  • Default is combined: core, es2015 and functional