租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
4.3 KiB

6 months ago
  1. # eslint-config-airbnb-base <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
  2. [![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)][package-url]
  3. [![github actions][actions-image]][actions-url]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config.
  7. ## Usage
  8. We export two ESLint configurations for your usage.
  9. ### eslint-config-airbnb-base
  10. Our default export contains all of our ESLint rules, including ECMAScript 6+. It requires `eslint` and `eslint-plugin-import`.
  11. 1. Install the correct versions of each package, which are listed by the command:
  12. ```sh
  13. npm info "eslint-config-airbnb-base@latest" peerDependencies
  14. ```
  15. If using **npm 5+**, use this shortcut
  16. ```sh
  17. npx install-peerdeps --dev eslint-config-airbnb-base
  18. ```
  19. If using **yarn**, you can also use the shortcut described above if you have npm 5+ installed on your machine, as the command will detect that you are using yarn and will act accordingly.
  20. Otherwise, run `npm info "eslint-config-airbnb-base@latest" peerDependencies` to list the peer dependencies and versions, then run `yarn add --dev <dependency>@<version>` for each listed peer dependency.
  21. If using **npm < 5**, Linux/OSX users can run
  22. ```sh
  23. (
  24. export PKG=eslint-config-airbnb-base;
  25. npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
  26. )
  27. ```
  28. Which produces and runs a command like:
  29. ```sh
  30. npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
  31. ```
  32. If using **npm < 5**, Windows users can either install all the peer dependencies manually, or use the [install-peerdeps](https://github.com/nathanhleung/install-peerdeps) cli tool.
  33. ```sh
  34. npm install -g install-peerdeps
  35. install-peerdeps --dev eslint-config-airbnb-base
  36. ```
  37. The cli will produce and run a command like:
  38. ```sh
  39. npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
  40. ```
  41. 2. Add `"extends": "airbnb-base"` to your .eslintrc.
  42. ### eslint-config-airbnb-base/legacy
  43. Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
  44. 1. Install the correct versions of each package, which are listed by the command:
  45. ```sh
  46. npm info "eslint-config-airbnb-base@latest" peerDependencies
  47. ```
  48. Linux/OSX users can run
  49. ```sh
  50. (
  51. export PKG=eslint-config-airbnb-base;
  52. npm info "$PKG" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG"
  53. )
  54. ```
  55. Which produces and runs a command like:
  56. ```sh
  57. npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
  58. ```
  59. 2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
  60. See [Airbnb's overarching ESLint config](https://npmjs.com/eslint-config-airbnb), [Airbnb's JavaScript styleguide](https://github.com/airbnb/javascript), and the [ESlint config docs](https://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information.
  61. ### eslint-config-airbnb-base/whitespace
  62. This entry point only errors on whitespace rules and sets all other rules to warnings. View the list of whitespace rules [here](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js).
  63. ## Improving this config
  64. Consider adding test cases if you're making complicated rules changes, like anything involving regexes. Perhaps in a distant future, we could use literate programming to structure our README as test cases for our .eslintrc?
  65. You can run tests with `npm test`.
  66. You can make sure this module lints with itself using `npm run lint`.
  67. [package-url]: https://npmjs.org/package/eslint-config-airbnb-base
  68. [npm-version-svg]: https://versionbadg.es/airbnb/javascript.svg
  69. [license-image]: https://img.shields.io/npm/l/eslint-config-airbnb-base.svg
  70. [license-url]: LICENSE.md
  71. [downloads-image]: https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg
  72. [downloads-url]: https://npm-stat.com/charts.html?package=eslint-config-airbnb-base
  73. [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/airbnb/javascript
  74. [actions-url]: https://github.com/airbnb/javascript/actions