Skip to content

Commit

Permalink
deps: update eslint to v9 add formatting rules and remove unused deps (
Browse files Browse the repository at this point in the history
…#4255)

* deps: update eslint to v9 add formatting rules and remove unused deps

* update github action linting

* autofix linting

* fix non autofix linting issues

* remove vim setting comment

* update @vitest/eslint-plugin
  • Loading branch information
daniele-mng authored Dec 18, 2024
1 parent 8d6368c commit 6345964
Show file tree
Hide file tree
Showing 1,588 changed files with 9,172 additions and 16,034 deletions.
86 changes: 0 additions & 86 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
- name: Install dependencies
run: npm install
- name: Lint JavaScript files
run: npm run lint -- --format junit -o ${{ env.REPORT_FILE }}
run: npm run lint > ${{ env.REPORT_FILE }}
- name: Store Lint Results
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 3 additions & 1 deletion allowedSnakeCase.cjs → allowedSnakeCase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

module.exports = [
const allowedSnakeCase = [
'access_hosts',
'action_result',
'actions_column',
Expand Down Expand Up @@ -693,3 +693,5 @@ module.exports = [
'yes_no_props',
'zh_TW',
];

export default allowedSnakeCase;
138 changes: 138 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import pluginJs from '@eslint/js';
import pluginHeader from 'eslint-plugin-header';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';
import * as importPlugin from 'eslint-plugin-import';
import vitest from '@vitest/eslint-plugin';
import allowedSnakeCase from './allowedSnakeCase.js';

pluginHeader.rules.header.meta.schema = false; // https://github.com/Stuk/eslint-plugin-header/issues/57

export default [
pluginJs.configs.recommended,
pluginReact.configs.flat?.recommended,
{
ignores: ['build', 'eslint.config.js'],
},
{
files: ['**/*.{js,mjs,cjs,jsx}'],
},
{
plugins: {
react: pluginReact,
'react-hooks': pluginReactHooks,
vitest,
import: importPlugin,
header: pluginHeader,
},
},
{
settings: {
react: {
version: 'detect',
},
},
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
...globals.node,
describe: 'readonly',
it: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
vi: 'readonly',
},
},
},
{
rules: {
...pluginReactHooks.configs.recommended.rules,
'react/react-in-jsx-scope': 'off',
'react/prop-types': [
'warn',
{
ignore: ['children', 'className', 'location'],
},
],
'no-unused-vars': [
'warn',
{
args: 'none',
ignoreRestSiblings: true,
},
],
camelcase: [
'warn',
{
allow: allowedSnakeCase,
properties: 'always',
},
],
'react/display-name': 'off',
'no-class-assign': 'off',
'no-prototype-builtins': 'off',
'no-case-declarations': 'off',
'react-hooks/exhaustive-deps': 'warn',
'header/header': [
2,
'block',
[
{
pattern: ' SPDX-FileCopyrightText: \\d{4} Greenbone AG',
template: ' SPDX-FileCopyrightText: 2024 Greenbone AG',
},
' *',
' * SPDX-License-Identifier: AGPL-3.0-or-later',
' ',
],
2,
],
'react/jsx-sort-props': [
'error',
{
callbacksLast: true,
shorthandFirst: true,
ignoreCase: false,
reservedFirst: true,
noSortAlphabetically: false,
},
],
'import/order': [
'error',
{
groups: [
['builtin', 'external'],
['internal'],
['parent', 'sibling', 'index'],
],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
},

{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
plugins: {vitest},
rules: {
...vitest.configs.recommended.rules,
'vitest/no-focused-tests': 'error',
'vitest/no-disabled-tests': 'warn',
'vitest/no-identical-title': 'error',
'react/prop-types': 'off',
},
},
];
Loading

0 comments on commit 6345964

Please sign in to comment.