Skip to content
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

Only functions names can have verbs (get, set, create, remove) #617

Open
fregante opened this issue Mar 19, 2020 · 12 comments
Open

Only functions names can have verbs (get, set, create, remove) #617

fregante opened this issue Mar 19, 2020 · 12 comments
Labels
evaluating new rule types Issues that happen in TypeScript or that require types

Comments

@fregante
Copy link
Collaborator

fregante commented Mar 19, 2020

OK

function getMozzarella() {}
const createPizza = async () => {}


const mozzarella = getMozzarella();
const pizza = await createPizza(mozzarella);

NOT OK

const getMozzarella = await api();
const createPizza = new Pizza();

There are many verbs that should not be part of non-function variables, but I think the most common ones are enough:

get
set
unset
delete
add
remove
destroy

Maybe not:

clear // this is also an adjective
init // this could also be a noun for "initialization of X", a Promise that resolves with X
@sindresorhus
Copy link
Owner

Have you actually experienced this being a problem in the wild?

@sindresorhus
Copy link
Owner

What if it's a factory?

const getRandom = random({{from: 0, to: 10});

@fregante
Copy link
Collaborator Author

fregante commented Mar 19, 2020

getRandom is a function, so that's fine

@fregante
Copy link
Collaborator Author

fregante commented Mar 19, 2020

Have you actually experienced this being a problem in the wild?

Yep, twice today, you just saw it too

Line 22: refined-github/refined-github@12711ca#diff-f12ecb2375f1a7fe299ae1d0f3a1e55dR22
Line 23: refined-github/refined-github@12711ca#diff-f12ecb2375f1a7fe299ae1d0f3a1e55dR23

@sindresorhus
Copy link
Owner

getRandom is a function, so that's fine

But how do we statically detect that? It will only work if you actually call getRandom in the current scope or a child scope.

@fregante
Copy link
Collaborator Author

But how do we statically detect that?

TypeScript?

@sindresorhus
Copy link
Owner

Related: #347

@fregante fregante changed the title Rule proposal: only functions names can have verbs (get, set, create, remove) Only functions names can have verbs (get, set, create, remove) Oct 1, 2020
@sindresorhus
Copy link
Owner

@fregante Can you try proposing this over at https://github.com/typescript-eslint/typescript-eslint first? If they, decline it, we can consider adding it here.

@fregante
Copy link
Collaborator Author

I opened a more generic issue there

@fregante
Copy link
Collaborator Author

fregante commented Nov 9, 2021

It doesn't look like it will be accepted

@fisker
Copy link
Collaborator

fisker commented Nov 9, 2021

It's a good idea, but like impossible to implement without type info.

@fregante
Copy link
Collaborator Author

fregante commented Aug 5, 2023

Issue rightfully rejected there:

I think this could be implemented in a flat config with naming-convention or by just customizing it in XO. Should I open an issue on XO?

@fregante fregante added the types Issues that happen in TypeScript or that require types label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluating new rule types Issues that happen in TypeScript or that require types
Projects
None yet
Development

No branches or pull requests

3 participants