Skip to content

Commit 970be42

Browse files
committed
style: Converted ESLint config
1 parent 87cabfd commit 970be42

File tree

2 files changed

+150
-120
lines changed

2 files changed

+150
-120
lines changed

.eslintrc.js

-120
This file was deleted.

eslint.config.mjs

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import 'eslint-plugin-only-warn';
2+
3+
import globals from 'globals';
4+
import pluginJs from '@eslint/js';
5+
import tseslint from 'typescript-eslint';
6+
import prettier from 'eslint-plugin-prettier/recommended';
7+
import * as unicorn from 'eslint-plugin-unicorn';
8+
import perfectionist from 'eslint-plugin-perfectionist';
9+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
10+
import wixEditor from 'eslint-plugin-wix-editor';
11+
import { fixupPluginRules } from '@eslint/compat';
12+
import * as regexpPlugin from 'eslint-plugin-regexp';
13+
14+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
15+
export default [
16+
pluginJs.configs.recommended,
17+
...tseslint.configs.recommended,
18+
...tseslint.configs.recommendedTypeChecked,
19+
regexpPlugin.configs['flat/recommended'],
20+
prettier,
21+
{
22+
ignores: ['dist/', 'coverage/', '@generated/**', '*.config.[cm]js', '.*rc.js'],
23+
languageOptions: {
24+
globals: globals.node,
25+
parserOptions: {
26+
project: ['./tsconfig.json'],
27+
warnOnUnsupportedTypeScriptVersion: false,
28+
tsconfigRootDir: import.meta.dirname,
29+
},
30+
},
31+
rules: {
32+
'max-lines': [1, { max: 300 }],
33+
'max-params': [1, { max: 5 }],
34+
'no-unneeded-ternary': [1],
35+
},
36+
},
37+
{
38+
plugins: {
39+
'wix-editor': fixupPluginRules(wixEditor),
40+
},
41+
rules: {
42+
'wix-editor/no-instanceof-array': 1,
43+
'wix-editor/no-not-not': 1,
44+
'wix-editor/no-unneeded-match': 1,
45+
'wix-editor/prefer-filter': 1,
46+
'wix-editor/prefer-ternary': 1,
47+
'wix-editor/return-boolean': 1,
48+
'wix-editor/simplify-boolean-expression': 1,
49+
},
50+
},
51+
{
52+
...unicorn.configs['flat/recommended'],
53+
rules: {
54+
'unicorn/prevent-abbreviations': [
55+
'warn',
56+
{
57+
replacements: {
58+
args: false,
59+
},
60+
},
61+
],
62+
},
63+
},
64+
{
65+
plugins: {
66+
perfectionist,
67+
},
68+
rules: {
69+
'perfectionist/sort-objects': [
70+
'warn',
71+
{
72+
type: 'natural',
73+
order: 'asc',
74+
},
75+
],
76+
},
77+
},
78+
{
79+
plugins: {
80+
'simple-import-sort': simpleImportSort,
81+
},
82+
rules: {
83+
'simple-import-sort/imports': 'warn',
84+
'simple-import-sort/exports': 'warn',
85+
},
86+
},
87+
{
88+
rules: {
89+
// core
90+
'consistent-return': [0, { treatUndefinedAsUnspecified: false }],
91+
quotes: [1, 'single', { allowTemplateLiterals: true, avoidEscape: true }],
92+
semi: [1, 'always'],
93+
'max-lines': [1, { max: 300 }],
94+
'max-params': [1, { max: 5 }],
95+
'no-unneeded-ternary': [1],
96+
// wix-editor
97+
'wix-editor/no-instanceof-array': 1,
98+
'wix-editor/no-not-not': 1,
99+
'wix-editor/no-unneeded-match': 1,
100+
'wix-editor/prefer-filter': 1,
101+
'wix-editor/prefer-ternary': 1,
102+
'wix-editor/return-boolean': 1,
103+
'wix-editor/simplify-boolean-expression': 1,
104+
// unicorn
105+
'unicorn/prefer-spread': 0,
106+
'unicorn/catch-error-name': 0,
107+
'unicorn/prefer-node-protocol': 0,
108+
'unicorn/prevent-abbreviations': [
109+
1,
110+
{
111+
replacements: {
112+
args: false,
113+
err: false,
114+
prod: false,
115+
ref: false,
116+
params: false,
117+
},
118+
},
119+
],
120+
// simple-import-sort with recomended settings
121+
'simple-import-sort/imports': 1,
122+
'sort-imports': 'off',
123+
'import/order': 'off',
124+
// typescript-eslint
125+
'@typescript-eslint/no-floating-promises': 1,
126+
'@typescript-eslint/no-unnecessary-condition': 1,
127+
'@typescript-eslint/explicit-module-boundary-types': 0,
128+
'@typescript-eslint/unbound-method': 0,
129+
},
130+
},
131+
{
132+
files: ['*.spec.ts', '**/{test,@generated}/**/*.ts'],
133+
rules: {
134+
'consistent-return': 0,
135+
'max-lines': 0,
136+
'regexp/strict': 0,
137+
'@typescript-eslint/no-misused-promises': 0,
138+
'@typescript-eslint/no-explicit-any': 0,
139+
'@typescript-eslint/no-unsafe-member-access': 0,
140+
'@typescript-eslint/no-floating-promises': 0,
141+
'@typescript-eslint/no-non-null-assertion': 0,
142+
'@typescript-eslint/camelcase': 0,
143+
'@typescript-eslint/no-unsafe-assignment': 0,
144+
'@typescript-eslint/no-unused-vars': 0,
145+
'@typescript-eslint/no-unsafe-return': 0,
146+
'@typescript-eslint/no-non-null-asserted-optional-chain': 0,
147+
'import/max-dependencies': 0,
148+
},
149+
},
150+
];

0 commit comments

Comments
 (0)