- Adiciona variáveis globais do Node.js (process, console, __dirname, require, module, exports) - Adiciona variáveis globais do Jest (describe, it, beforeEach, fail, etc.) - Configura ESLint para arquivos JavaScript de configuração - Remove diretivas eslint-disable não utilizadas - Corrige variáveis não usadas prefixando com _ - Ajusta regras do ESLint para ignorar variáveis que começam com _ - Formata código com Prettier
112 lines
2.9 KiB
JavaScript
112 lines
2.9 KiB
JavaScript
const js = require('@eslint/js');
|
|
const parser = require('@typescript-eslint/parser');
|
|
const plugin = require('@typescript-eslint/eslint-plugin');
|
|
const prettierPlugin = require('eslint-plugin-prettier');
|
|
const prettierConfig = require('eslint-config-prettier');
|
|
|
|
module.exports = [
|
|
js.configs.recommended,
|
|
prettierConfig,
|
|
{
|
|
files: ['**/*.ts'],
|
|
languageOptions: {
|
|
parser: parser,
|
|
parserOptions: {
|
|
project: './tsconfig.json',
|
|
sourceType: 'module',
|
|
},
|
|
globals: {
|
|
node: true,
|
|
jest: true,
|
|
process: 'readonly',
|
|
console: 'readonly',
|
|
__dirname: 'readonly',
|
|
__filename: 'readonly',
|
|
require: 'readonly',
|
|
module: 'readonly',
|
|
exports: 'readonly',
|
|
describe: 'readonly',
|
|
it: 'readonly',
|
|
test: 'readonly',
|
|
expect: 'readonly',
|
|
beforeEach: 'readonly',
|
|
afterEach: 'readonly',
|
|
beforeAll: 'readonly',
|
|
afterAll: 'readonly',
|
|
fail: 'readonly',
|
|
},
|
|
},
|
|
plugins: {
|
|
'@typescript-eslint': plugin,
|
|
prettier: prettierPlugin,
|
|
},
|
|
rules: {
|
|
...plugin.configs.recommended.rules,
|
|
'@typescript-eslint/interface-name-prefix': 'off',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
'@typescript-eslint/no-require-imports': 'warn',
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
'no-useless-escape': 'warn',
|
|
'no-import-assign': 'off',
|
|
'prettier/prettier': 'error',
|
|
},
|
|
},
|
|
{
|
|
files: ['**/*.spec.ts', '**/__tests__/**/*.ts', '**/test/**/*.ts'],
|
|
languageOptions: {
|
|
globals: {
|
|
describe: 'readonly',
|
|
it: 'readonly',
|
|
test: 'readonly',
|
|
expect: 'readonly',
|
|
beforeEach: 'readonly',
|
|
afterEach: 'readonly',
|
|
beforeAll: 'readonly',
|
|
afterAll: 'readonly',
|
|
jest: 'readonly',
|
|
fail: 'readonly',
|
|
require: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['**/*.js'],
|
|
languageOptions: {
|
|
globals: {
|
|
node: true,
|
|
jest: true,
|
|
process: 'readonly',
|
|
console: 'readonly',
|
|
__dirname: 'readonly',
|
|
__filename: 'readonly',
|
|
require: 'readonly',
|
|
module: 'readonly',
|
|
exports: 'readonly',
|
|
global: 'readonly',
|
|
Buffer: 'readonly',
|
|
},
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'commonjs',
|
|
},
|
|
rules: {
|
|
'no-undef': 'off',
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
},
|
|
},
|
|
{
|
|
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
|
|
},
|
|
];
|