How to set ESLint rule to accept snake_case?

Viewed 6752

always errors

  `16:3  error  Property name `type_array` must match one of the following formats: camelCase, UPPER_CASE, PascalCase    @typescript-eslint/naming-convention
  16:3  error  Identifier 'type_array' is not in camel case 
16:3  error  Property name `instument_view_id` must match one of the following formats: camelCase, UPPER_CASE, PascalCase`

i try rules from the page https://eslint.org/docs/2.0.0/rules/camelcase add to .eslintrc.js variants but nothing work for me.. :(

  `rules: {
    camelcase: ['error', {properties: 'always'}],
  },
```
  rules: {
    camelcase: ['error', {allow: ['aa_bb']}],,
  },`
2 Answers

ESLint does not support snake_case. If you want to use snake_case, try this ESLint plugin.

Sometimes you cannot really fix this issue. For example I had this error when doing something like

this.httpClient.post<void>(url, body,{headers: new HttpHeaders({ 'Content-Type': 'application/json' })});

But it really makes no sense to change the http-header-property-name Content-Type to camelcase (because it will not work anymore) so unfortunately the only option for this purposes is inserting the line

// eslint-disable-next-line @typescript-eslint/naming-convention

before the line which causes the linting-message.

Related