From 7fd8039e208103246fecf04caab29a91ff6f0177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei=C3=9Fer=20Hase?= Date: Tue, 1 Oct 2024 10:55:42 -0300 Subject: [PATCH] fix: adding linter config --- js/eslint.config.mjs | 68 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 js/eslint.config.mjs diff --git a/js/eslint.config.mjs b/js/eslint.config.mjs new file mode 100644 index 0000000..ce186cc --- /dev/null +++ b/js/eslint.config.mjs @@ -0,0 +1,68 @@ +import { fixupConfigRules } from '@eslint/compat'; +import globals from 'globals'; +import babelParser from '@babel/eslint-parser'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: ['lib', 'dist'], +}, ...fixupConfigRules( + compat.extends('eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings'), +), { + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + parser: babelParser, + parserOptions: { + requireConfigFile: false, + }, + ecmaVersion: 8, + sourceType: 'module', + }, + + settings: { + react: { + version: 'detect', + }, + }, + + rules: { + 'no-trailing-spaces': ['error'], + 'import/first': ['error'], + 'import/no-commonjs': ['error'], + 'import/namespace': ['warn'], + + 'import/order': ['error', { + groups: [['internal', 'external', 'builtin'], ['index', 'sibling', 'parent']], + 'newlines-between': 'always', + }], + + indent: ['error', 2, { + MemberExpression: 1, + SwitchCase: 1, + }], + + 'linebreak-style': ['error', 'unix'], + 'no-console': [0], + + quotes: ['error', 'single', { + avoidEscape: true, + allowTemplateLiterals: true, + }], + + 'require-await': ['error'], + semi: ['error', 'always'], + }, +}]; \ No newline at end of file