cartant / eslint-plugin-rxjs

ESLint rules for RxJS
MIT License
311 stars 36 forks source link

Require finnish notation, but not on Subjects #99

Closed lundmikkel closed 2 years ago

lundmikkel commented 2 years ago

Is it possible to require observables to use finnish notation (obs$) and subjects to use Subject suffix, but not both?

const obs$:       Observable<void>; // Valid
const mySubject:  Subject<void>;    // Valid

const mySubject$: Subject<void>;    // Error
const my:         Subject<void>;    // Error

Our rules currently look somewhat like this:

"rxjs/finnish": [
  "error",
  {
    "functions": false,
    "methods": false,
    "names": {
      "^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$": false,
      "Subject$": false,
    },
    "parameters": true,
    "properties": true,
    "strict": true,
    "types": {
      "^EventEmitter$": false,
    },
    "variables": true,
  },
],
"rxjs/suffix-subjects": "error",
lundmikkel commented 2 years ago

Seems like I managed to find the solution:

"rxjs/finnish": [
  "error",
  {
    "functions": false,
    "methods": false,
    "names": {
      "^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$": false,
    },
    "parameters": true,
    "properties": true,
    "strict": true,
    "types": {
      "^EventEmitter$": false,
      "Subject$": false,
    },
    "variables": true,
  },
],
"rxjs/suffix-subjects": "error",

(Moved the "Subject$": false down to types instead)