-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to flat config format #609
Changes from all commits
5d73594
d78c4d2
6b9ad00
cc971da
c713ff3
cdeaa87
8843460
1645f31
a090c20
2b83141
53120db
2ad1513
4b72441
e614455
fc93e72
91f3865
314c440
6c23c09
8e773f9
2880934
1c016e4
3c9772d
766d0cc
002312b
8810dcd
a98d1ea
4bc9206
4d6c334
e85ae09
26d9fce
044acf5
ca13b87
71a7178
53b12b5
d073f2b
ca58850
0b353c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_style = tab | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
trim_trailing_whitespace = false | ||
|
||
# YAML files cannot have tabs | ||
# @see https://yaml.org/faq.html | ||
[*.yml] | ||
indent_style = space |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
node_modules | ||
/dist/*.js | ||
.vscode/ | ||
/fixtures/repos | ||
/tmp-eslint-config | ||
.vscode |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/* |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"extends": ["config:base", ":automergeMinor"], | ||
"reviewers": ["team:dev"], | ||
"dependencyDashboard": true, | ||
"stabilityDays": 4, | ||
"packageRules": [ | ||
{ | ||
"matchDepTypes": ["dependencies"], | ||
"rangeStrategy": "bump" | ||
}, | ||
{ | ||
"matchPackagePatterns": ["eslint"], | ||
"automerge": false | ||
} | ||
] | ||
"extends": ["config:base", ":automergeMinor"], | ||
"reviewers": ["team:dev"], | ||
"dependencyDashboard": true, | ||
"stabilityDays": 4, | ||
"packageRules": [ | ||
{ | ||
"matchDepTypes": ["dependencies"], | ||
"rangeStrategy": "bump" | ||
}, | ||
{ | ||
"matchPackagePatterns": ["eslint"], | ||
"automerge": false | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
# Contributing Guide | ||
|
||
## Running @cloudfour/eslint-plugin on itself | ||
## Release Process | ||
|
||
In order to run `npm run lint` on this project, it needs to have a symlink to itself in `node_modules`, so that ESLint can find it. To set up this symlink, run `npm link` and then `npm link @cloudfour/eslint-plugin`. Then you should be able to run `npm run lint`. | ||
|
||
## Pull Requests | ||
|
||
If you are submitting a pull request that includes changes that will affect places where this ESLint config is installed, add a Changeset file to describe the outward-facing changes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changesets is nice, but a bit of a maintenance burden. I opted to rip it out and just use a standard release process like we do for our Stylelint config. |
||
|
||
- On your feature branch, run `npx changeset`. | ||
|
||
- First it will ask you what [kind of change it is](https://semver.org/#summary): | ||
|
||
- **Major changes** include | ||
- Enabling rules | ||
- Removing rules | ||
- Bugfixes to rules that are likely to error on more code than before | ||
- Removing support for Node or ESLint or TypeScript versions | ||
- **Minor changes** include | ||
- Creating rules that are not enabled by default | ||
- Adding support for Node or ESLint or TypeScript versions | ||
- Bugfixes to rules that are not likely to error on more code than before | ||
- **Patch releases** include | ||
- Bugfixes/refactorings that will not change the functionality | ||
|
||
Dependency updates can fall into any of the three categories, consider how the dependency change will affect consumers of this ESLint config. | ||
|
||
- Next it will ask you to describe your changes. This message will appear in the Changelog. You can press enter before you type anything to edit the message in your editor. | ||
|
||
## Releasing | ||
|
||
- [Changesets Action](https://github.com/changesets/action) will create and maintain release PR's whenever changes are pushed to main. Merge the "Publish Next Version" PR to release all unreleased changes on `main`. All of the changes will get combined into a single release. Changesets will handle updating the changelog, pushing git tags, and publishing to npm. | ||
[How to publish an updated version](https://cloudfour.com/thinks/how-to-publish-an-updated-version-of-an-npm-package/) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,43 @@ | ||
# @cloudfour/eslint-plugin | ||
# @cloudfour/eslint-config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fun bit of history here — This repo is called One of Caleb's first tasks was bumping the version number to Then he converted it to a super-plugin, and changed the package name to Since then, we've released 20+ versions, bumping whenever a dependency released a major version. Now, I'm converting it back to the config, and reclaiming the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After further consideration, I've restored the changelog and set the version number to 24. No sense throwing out our history just because the package name changed again. |
||
|
||
[](https://www.npmjs.com/package/@cloudfour/eslint-plugin) [](https://github.com/cloudfour/eslint-config/actions?query=workflow%3ACI) [](https://renovatebot.com) | ||
[](https://www.npmjs.com/package/@cloudfour/eslint-config) [](https://github.com/cloudfour/eslint-config/actions?query=workflow%3ACI) [](https://renovatebot.com) | ||
|
||
Cloud Four's ESLint configuration. This exports itself as a "super-plugin" because of a [limitation of ESLint](https://github.com/eslint/eslint/issues/3458). | ||
Cloud Four's ESLint configuration. | ||
|
||
The way this works is that it requires all of the plugin dependencies, and exports them from this plugin under a prefix. | ||
|
||
The plugins that this exposes are: | ||
This config extends the following plugins: | ||
|
||
- [`n`](https://github.com/weiran-zsd/eslint-plugin-node) (maintained fork of original [`eslint-plugin-node`](https://github.com/mysticatea/eslint-plugin-node)) | ||
- [`import`](https://github.com/benmosher/eslint-plugin-import) | ||
- [`standard`](https://github.com/standard/eslint-plugin-standard) | ||
- [`promise`](https://github.com/xjamundx/eslint-plugin-promise) | ||
- [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn) | ||
- [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc) | ||
- [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn) | ||
- [`standard`](https://github.com/standard/eslint-config-standard) | ||
- [`@typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) | ||
|
||
To override settings for any of these plugins, you must prefix the configuration | ||
with `cloudfour/`, because the plugins are exposed through this "super-plugin". | ||
|
||
```json | ||
{ | ||
"extends": ["plugin:@cloudfour/recommended"], | ||
"rules": { | ||
"@cloudfour/promise/no-native": "off" | ||
} | ||
} | ||
``` | ||
|
||
In addition to the `recommended` configuration, `@cloudfour/eslint-plugin` also re-exports typescript-eslint's [`disable-type-checked` configuration](https://typescript-eslint.io/linting/configs/#disable-type-checked). This configuration disables any rules that depend on typescript-eslint's typescript integration. | ||
|
||
## Installation | ||
It also adds the following custom rules: | ||
|
||
```sh | ||
npm install --save-dev @cloudfour/eslint-plugin eslint prettier | ||
``` | ||
- [`prefer-early-return`](./rules/prefer-early-return/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm kind of surprised this isn't part of one of the plugins we extend. This is a great rule |
||
|
||
## Usage | ||
|
||
Add this to your `package.json`: | ||
|
||
```json | ||
"scripts": { | ||
"check-lint": "eslint . && prettier --check .", | ||
"lint": "eslint --fix . && prettier --write ." | ||
}, | ||
"eslintConfig": { | ||
"extends": "plugin:@cloudfour/recommended" | ||
}, | ||
"prettier": { | ||
"singleQuote": true | ||
} | ||
``` | ||
|
||
### Check for Lint Errors | ||
This package exports [a flat ESLint configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new). | ||
|
||
```sh | ||
npm run check-lint | ||
```bash | ||
npm install --save-dev eslint @cloudfour/eslint-config | ||
``` | ||
|
||
### Fix Lint Errors | ||
Example `eslint.config.js`: | ||
|
||
This command will attempt to automatically fix lint errors. Note that not all lint errors can be fixed this way, so be prepeared to fix any remaining errors by hand. | ||
```js | ||
import cloudFourConfig from '@cloudfour/eslint-config'; | ||
|
||
```sh | ||
npm run lint | ||
export default [ | ||
...cloudFourConfig, | ||
{ | ||
rules: { | ||
// your overrides here | ||
... | ||
} | ||
}, | ||
]; | ||
``` | ||
|
||
### Troubleshooting Note | ||
|
||
This config relies on using a version of eslint installed locally to your project. If you also have eslint installed globally, it's possible to run into conflicts. To avoid any problems, either: | ||
|
||
- Just use the `npm run check-lint` and `npm run lint` scripts, which will run the local version of eslint. | ||
- Or, if you prefer to run eslint by hand, use [npx](https://www.npmjs.com/package/npx), which will run the local version of eslint. eg, `npx eslint '**/*.js'` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates to the editorconfig. 👍🏽