forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
108 lines (105 loc) · 3.18 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
const fs = require('fs')
const path = require('path')
const { specifiedRules } = require('graphql')
const graphqlOpts = {
env: 'literal',
tagName: 'gql',
// eslint-disable-next-line no-restricted-syntax
schemaString: fs.readFileSync(
path.join(__dirname, 'packages/graphql/schemas/schema.graphql'),
'utf8',
),
}
const validators = specifiedRules
.map((rule) => rule.name)
.filter(
(ruleName) => {
return [
'NoUnusedFragmentsRule',
'KnownFragmentNamesRule',
'NoUnusedVariablesRule',
].findIndex((x) => x === ruleName) === -1
},
)
module.exports = {
root: true,
plugins: [
'@cypress/dev',
'graphql',
],
extends: [
'plugin:@cypress/dev/general',
'plugin:@cypress/dev/tests',
],
parser: '@typescript-eslint/parser',
ignorePatterns: [
// cli types are checked by dtslint
'cli/types/**',
// these fixtures are supposed to fail linting
'npm/eslint-plugin-dev/test/fixtures/**',
],
overrides: [
{
files: [
// ignore in tests and scripts
'**/scripts/**',
'**/test/**',
'**/system-tests/**',
'tooling/**',
'packages/{app,driver,frontend-shared,launchpad}/cypress/**',
'*.test.ts',
// ignore in packages that don't run in the Cypress process
'npm/create-cypress-tests/**',
],
rules: {
'no-restricted-properties': 'off',
'no-restricted-syntax': 'off',
},
},
],
rules: {
'no-duplicate-imports': 'off',
'import/no-duplicates': 'off',
'@typescript-eslint/no-duplicate-imports': [
'error',
],
'prefer-spread': 'off',
'prefer-rest-params': 'off',
'no-useless-constructor': 'off',
'no-restricted-properties': [
'error',
{
object: 'process',
property: 'geteuid',
message: 'process.geteuid() will throw on Windows. Do not use it unless you catch any potential errors.',
},
{
object: 'os',
property: 'userInfo',
message: 'os.userInfo() will throw when there is not an `/etc/passwd` entry for the current user (like when running with --user 12345 in Docker). Do not use it unless you catch any potential errors.',
},
],
'no-restricted-syntax': [
// esquery tool: https://estools.github.io/esquery/
'error',
{
// match sync FS methods except for `existsSync`
// examples: fse.readFileSync, fs.readFileSync, this.ctx.fs.readFileSync...
selector: `MemberExpression[object.name='fs'][property.name=/^[A-z]+Sync$/]:not(MemberExpression[property.name='existsSync']), MemberExpression[property.name=/^[A-z]+Sync$/]:not(MemberExpression[property.name='existsSync']):has(MemberExpression[property.name='fs'])`,
message: 'Synchronous fs calls should not be used in Cypress. Use an async API instead.',
},
],
'graphql/capitalized-type-name': ['warn', graphqlOpts],
'graphql/no-deprecated-fields': ['error', graphqlOpts],
'graphql/template-strings': ['error', { ...graphqlOpts, validators }],
'graphql/required-fields': [
'error',
{ ...graphqlOpts, requiredFields: ['id'] },
],
},
settings: {
react: {
version: '16.8',
},
},
}