-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.eslintrc.cjs
62 lines (58 loc) · 1.77 KB
/
.eslintrc.cjs
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
const fs = require('fs');
const path = require('path');
// eslint-disable-next-line import/no-extraneous-dependencies
const fg = require('fast-glob');
const { packages: workspaces } = require('./package.json').workspaces;
const projectDirs = workspaces
.flatMap(pattern => fg.sync(pattern, { onlyDirectories: true }))
.filter(projectPath =>
fs.existsSync(path.join(__dirname, projectPath, 'package.json'))
);
const devDependencies = [
'**/test/**/*.{html,js,mjs,ts}',
'**/stories/**/*.{html,js,mjs,ts}',
'**/*.config.{html,js,mjs,ts}',
'**/*.conf.{html,js,mjs,ts}',
];
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['@open-wc', 'prettier'],
plugins: ['@typescript-eslint'],
ignorePatterns: ['**/locales/*.ts'],
rules: {
'no-unused-vars': 'off',
'class-methods-use-this': 'off',
'@typescript-eslint/no-unused-vars': ['off'],
'import/no-unresolved': 'off',
'import/extensions': [
'error',
'always',
{
ignorePackages: true,
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [...devDependencies, 'tasks/*.js'],
},
],
},
// eslint-plugin-import should support yarn workspaces, but still, apparently not
// from https://github.com/import-js/eslint-plugin-import/issues/1913#issuecomment-1034025709
// see https://github.com/import-js/eslint-plugin-import/issues/1174
overrides: projectDirs.map(projectDir => ({
files: [`${projectDir}/**/*.{t,j}s`],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies,
packageDir: [__dirname, path.join(__dirname, projectDir)],
},
],
},
})),
};