-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
126 lines (125 loc) · 4 KB
/
.eslintrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const getImportGroups = () => {
const external = ['astro:', '@astrojs'];
const internal = ['layouts/**', 'pages/**', 'components/**', 'utils/**', 'theme/**', 'constants/**', 'assets/**'];
return external
.map(pattern => ({ pattern, group: 'external', position: 'before' }))
.concat(
internal.map(pattern => ({
pattern,
group: 'internal',
position: 'before',
}))
);
};
module.exports = {
root: true,
env: {
node: true,
es2022: true,
browser: true,
},
extends: [
'semistandard',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:astro/recommended',
'plugin:astro/jsx-a11y-recommended',
'plugin:sonarjs/recommended',
'plugin:promise/recommended',
'prettier',
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'global-require': 'off',
'no-restricted-exports': 'off',
'sonarjs/no-duplicate-string': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'func-names': 'off',
'no-param-reassign': 'off',
'no-unused-vars': ['error', { argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' }],
'sort-imports': 'off', // turned off in favour of import/order rule
'import/order': [
'error',
{
'newlines-between': 'ignore',
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: getImportGroups(),
pathGroupsExcludedImportTypes: ['react'],
},
],
'import/no-unresolved': ['error', { ignore: ['^virtual:', '^astro:'] }],
'promise/always-return': ['error', { ignoreLastCallback: true }],
'no-useless-constructor': 'off',
'lines-between-class-members': 'off',
},
plugins: ['only-warn'],
overrides: [
{
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
rules: {
'astro/jsx-a11y/anchor-has-content': 'off',
'astro/jsx-a11y/media-has-caption': 'off',
},
},
{
// Define the configuration for `<script>` tag.
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
files: ['**/*.astro/*.js', '*.astro/*.js'],
parser: '@typescript-eslint/parser',
},
{
files: ['*.md', '*.mdx'],
parser: 'eslint-plugin-markdownlint/parser',
extends: ['plugin:markdownlint/recommended'],
rules: {
'markdownlint/md033': 'off', // allow html tags
'markdownlint/md013': 'off', // no limit on line length
'markdownlint/md014': 'off', // allow $ prefix for shell cmds
'markdownlint/md041': 'off', // disable h1 first rule
'markdownlint/md004': ['error', { style: 'dash' }], // dash ul
'markdownlint/md049': ['error', { style: 'asterisk' }], // asterisk em
'markdownlint/md050': ['error', { style: 'asterisk' }], // asterisk b
'markdownlint/md003': ['error', { style: 'atx' }], // atx style headings
'markdownlint/md035': ['error', { style: '---' }], // style for hr
'markdownlint/md048': ['error', { style: 'backtick' }], // codefence style
},
},
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.js', '.jsx', '.ts', '.tsx'],
},
'import/ignore': ['node_modules'],
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
alias: {
map: [
['layout', './src/layouts'],
['pages', './src/pages'],
['components', './src/components'],
['utils', './src/utils'],
['theme', './src/theme'],
['constants', './src/constants'],
['assets', './src/assets'],
['appConfig', './appConfig'],
['@astrojs/image/components', ''],
],
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx', '.astro'],
},
},
settings: {
'mdx/code-blocks': true,
},
},
};