Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

Commit

Permalink
feat(core): require issue urls for todos and fixmes
Browse files Browse the repository at this point in the history
BREAKING CHANGE: all todo and fixme comments are now required to have an issue url attached at the
end

#8
  • Loading branch information
vuki656 committed May 9, 2022
1 parent 046c93a commit be713a4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"tabWidth": 4,
"useTabs": false,
"semi": false,
"singleQuote": true
"singleQuote": true,
"proseWrap": "always",
"printWidth": 110
}
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ yarn add -D
}
```

3. Make sure the `project` field (under `parserOptions`) is pointing to the
correct path to your `tsconfig.json`
3. Make sure the `project` field (under `parserOptions`) is pointing to the correct path to your
`tsconfig.json`

## Optional Rulesets

Add the following ruleset to your `.eslintrc.json` file under
`extends` section (example below)
Add the following ruleset to your `.eslintrc.json` file under `extends` section (example below)

- `"@rimac-technology/eslint-config/react"`
- `"@rimac-technology/eslint-config/jest"`
Expand All @@ -62,18 +61,14 @@ Add the following ruleset to your `.eslintrc.json` file under

`Testing Library`

- If you prefer more granular control of which files
`eslint-plugin-testing-library` considers for test files and lints
you can change `"files"` field.
- If you prefer more granular control of which files `eslint-plugin-testing-library` considers for test
files and lints you can change `"files"` field.

```json
{
"overrides": [
{
"files": [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)"
],
"files": ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).[jt]s?(x)"],
"extends": ["@rimac-technology/eslint-config/testing-library"]
}
]
Expand All @@ -91,8 +86,7 @@ Add the following ruleset to your `.eslintrc.json` file under

## Overriding or Adding Custom Rules

Rules can be overridden by adding them to the
`rules` section in `.eslintrc.json` like the following example
Rules can be overridden by adding them to the `rules` section in `.eslintrc.json` like the following example

```json
{
Expand All @@ -115,8 +109,8 @@ Little fellow sometimes has problems. Here is how to help if it doesn't work:

## Testing Locally

In `package.json`, specify the path to the folder where you cloned `eslint-config`
on your computer and place it instead of the version.
In `package.json`, specify the path to the folder where you cloned `eslint-config` on your computer and place
it instead of the version.

Then you can use it like any other lib.

Expand Down
34 changes: 34 additions & 0 deletions RULE_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Rule Setup

Instructions on how to setup rules that require configuration

## `todos/only-documented-todos`

- This rule checks that all your `FIXMEs` and `TODOs` have an issue url attached to them

**Setup**

- Add a new `bugs` section to `package.json` (check the `package.json` example snippet below) that will
contain the `url` where all the issues are opened for your project
- You can find which url to put by opening a single issue, for example
`https://rimac-automobili.atlassian.net/browse/TEL-4380` and taking just the part that will never
change `https://rimac-automobili.atlassian.net/browse/TEL-` and put that in the `url`. Note that only
the issue number at the end changes from issue to issue.
- All the future todo URLs will have to start with that url
- For example for the telemetry project the url is as listed below in the `package.json` example snippet and
the todos should be created as such

```typescript
// TODO: this needs to be better https://rimac-automobili.atlassian.net/browse/TEL-4380
const test = 1
```

```json
{
"name": "@rimac-technology/eslint-config",
"version": "23.0.0",
"bugs": {
"url": "https://rimac-automobili.atlassian.net/browse/TEL-"
}
}
```
8 changes: 8 additions & 0 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
'etc',
'@rimac-technology',
'eslint-comments',
'todos',
],
'rules': {
'@rimac-technology/import-declaration-newline': 'error',
Expand Down Expand Up @@ -428,6 +429,13 @@ module.exports = {
'space-in-parens': 'error',
'space-infix-ops': 'off',
'template-curly-spacing': 'error',
'todos/only-documented-todos': [
'warn',
{
'location': 'start',
'terms': ['todo', 'fixme'],
},
],
'typescript-sort-keys/interface': 'error',
'typescript-sort-keys/string-enum': 'error',
'unicorn/better-regex': 'error',
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eslint-plugin-sort-destructure-keys": "^1.4.0",
"eslint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-testing-library": "^5.0.6",
"eslint-plugin-todos": "^0.1.0",
"eslint-plugin-type-graphql": "^1.0.0",
"eslint-plugin-typescript-sort-keys": "^2.1.0",
"eslint-plugin-unicorn": "^41.0.0",
Expand Down
21 changes: 21 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ __metadata:
eslint-plugin-sort-destructure-keys: ^1.4.0
eslint-plugin-sort-keys-fix: ^1.1.2
eslint-plugin-testing-library: ^5.0.6
eslint-plugin-todos: ^0.1.0
eslint-plugin-type-graphql: ^1.0.0
eslint-plugin-typescript-sort-keys: ^2.1.0
eslint-plugin-unicorn: ^41.0.0
Expand Down Expand Up @@ -3622,6 +3623,13 @@ __metadata:
languageName: node
linkType: hard

"ellipsize@npm:0.1.0":
version: 0.1.0
resolution: "ellipsize@npm:0.1.0"
checksum: 2b2a78259206ead8a2f7b49b4c389dd8de32619ec1304eb042905a2c8b8b11b6a34f7e5f65ed43f29c9472af29531bb683e5a395e7b3dd51be95dd8096ccd426
languageName: node
linkType: hard

"emittery@npm:^0.8.1":
version: 0.8.1
resolution: "emittery@npm:0.8.1"
Expand Down Expand Up @@ -4011,6 +4019,19 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-todos@npm:^0.1.0":
version: 0.1.0
resolution: "eslint-plugin-todos@npm:0.1.0"
dependencies:
ellipsize: 0.1.0
lodash: ^4.17.15
read-pkg-up: ^7.0.1
peerDependencies:
eslint: ^6.8.0
checksum: 22e7b7cb5ff5559f54ef48cf9ff9acbfb806810dfd0c749ad1e9ae33dba40d2550cf43c73b202c1ff797b343039f42c7a2eb2ffb52da31469e0897c9d528dc1a
languageName: node
linkType: hard

"eslint-plugin-type-graphql@npm:^1.0.0":
version: 1.0.0
resolution: "eslint-plugin-type-graphql@npm:1.0.0"
Expand Down

0 comments on commit be713a4

Please sign in to comment.