TristonJ / eslint-plugin-prefer-arrow

ESLint plugin to prefer arrow functions
MIT License
54 stars 10 forks source link

allow-named-functions option #17

Open snebjorn opened 4 years ago

snebjorn commented 4 years ago

typescript-eslint lists this plugin as the TSLint replacement for only-arrow-functions https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/ROADMAP.md

If that's the case then it's missing the allow-named-functions option https://palantir.github.io/tslint/rules/only-arrow-functions/

I'd also very much appreciate a rule details page that describe why we would want to use the rule etc. Much like typescript-eslint do https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-inferrable-types.md

TristonJ commented 4 years ago

I think both of those things are good suggestions. Documentation is certainly lacking.

Adding the additional option should be fairly easy. This might be an argument to change our allowStandaloneDeclarations to allowDeclarations and match whatever functionality that package exposes.

I'll work on this stuff and close / comment this issue when I have something.

ahmedkotb commented 4 years ago

@TristonJ @snebjorn any update on this ? :)

rtruong commented 4 years ago

@TristonJ @snebjorn Any updates?

agataHappy commented 2 years ago

@TristonJ I see that there's PR that should add this option. Can it be merged soon?

Samuel-Therrien-Beslogic commented 2 years ago

For now I have an override in Angular that disables on classProperties in certain files

{
  // See no-restricted-syntax
  "files": ["*[.-]component.ts", "*[.-]interceptor.ts"],
  "rules": {
    // Angular hooks should be named functions
    // https://github.com/mojohaus/extra-enforcer-rules/issues/186
    "extra-rules/potential-point-free": "warn",
    "prefer-arrow/prefer-arrow-functions": [
      "error",
      {
        ...preferArrowFunctionsConfig,
        https://github.com/TristonJ/eslint-plugin-prefer-arrow/issues/17
        "classPropertiesAllowed": false,
      },
    ],
  },
},

But I would like to be able to tell this plugin to ignore: intercept, ngOnChanges, ngOnInit, ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAfterViewInit, ngAfterViewChecked, ngOnDestroy, ...