forked from opencollective/opencollective-frontend-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.eslintrc.json
134 lines (133 loc) · 4.84 KB
/
.eslintrc.json
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
127
128
129
130
131
132
133
134
{
"extends": ["opencollective", "plugin:styled-components-a11y/recommended", "plugin:import/typescript"],
"ignorePatterns": ["./lib/graphql/types/*"],
"env": { "jest": true },
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint/eslint-plugin",
"react-hooks",
"simple-import-sort",
"formatjs",
"styled-components-a11y"
],
"rules": {
"no-console": "error",
"no-process-env": "error",
"require-atomic-updates": "off",
// Typescript
"node/no-missing-import": ["error", { "tryExtensions": [".js", ".ts", ".tsx"] }],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
// -- End of typescript-specific config
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "react-intl",
"importNames": ["FormattedHTMLMessage"],
"message": "FormattedHTMLMessage is not allowed, please rely on the standard FormattedMessage."
}
]
}
],
"no-restricted-properties": [
"error",
{
"object": "it",
"property": "only",
"message": "it.only should only be used for debugging purposes and is not allowed in production code"
},
{
"object": "describe",
"property": "only",
"message": "describe.only should only be used for debugging purposes and is not allowed in production code"
}
],
"react-hooks/rules-of-hooks": ["error"],
"react/jsx-fragments": ["error", "element"],
// We can be stricter with these rules
// because we don't have any occurences anymore
"react/react-in-jsx-scope": ["error"],
"react/prop-types": ["off"],
"react/sort-comp": ["error"],
"react/no-this-in-sfc": ["error"],
// simple-import-sort
"simple-import-sort/imports": [
"error",
{
"groups": [
// Side effect imports.
["^\\u0000"],
// Node.js builtins. You could also generate this regex if you use a `.js` config.
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
[
"^(_http_agent|_http_client|_http_common|_http_incoming|_http_outgoing|_http_server|_stream_duplex|_stream_passthrough|_stream_readable|_stream_transform|_stream_wrap|_stream_writable|_tls_common|_tls_wrap|assert|async_hooks|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|http2|https|inspector|module|net|os|path|perf_hooks|process|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|trace_events|tty|url|util|v8|vm|worker_threads|zlib)(/|$)"
],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
["^react$", "^prop-types$", "^@?\\w"],
// Libs
["(.*)/lib/", "(.*)/server/", "(.*)/test/"],
// Components
["(.*)/components/"],
// Parent imports. Put `..` last.
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
// Other relative imports. Put same-folder imports and `.` last.
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
// Styles
["^.+\\.s?css$"],
// Images
["public/static/images", "^.+\\.svg$", "^.+\\.png$"]
]
}
],
// formatjs
"formatjs/enforce-default-message": ["error"],
"formatjs/enforce-plural-rules": ["error"],
"formatjs/no-multiple-whitespaces": ["error"],
"formatjs/no-offset": ["error"],
"formatjs/enforce-placeholders": ["off"],
"formatjs/no-camel-case": ["off"],
"formatjs/no-emoji": ["off"],
"formatjs/no-multiple-plurals": ["off"],
// styled-components-a11y
"jsx-a11y/anchor-is-valid": ["off"], // Not playing well with NextJS links
// This is deprecated and replaced by jsx-a11y/label-has-associated-control;
// https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md
"jsx-a11y/label-has-for": ["off"],
// The rational behind this is; https://github.com/brendanmorrell/eslint-plugin-styled-components-a11y/issues/18#issuecomment-837229005
"jsx-a11y/label-has-associated-control": [
"error",
{
"required": {
"some": ["nesting", "id"]
}
}
]
},
"overrides": [
{
"files": ["scripts/*.ts"],
"rules": {
"no-console": "off"
}
},
{
"files": [".jsx", ".jsx", "*.ts", "*.tsx"],
"processor": "@graphql-eslint/graphql",
"parserOptions": {
"schema": "./lib/graphql/schemaV2.graphql"
}
},
{
"files": ["*.graphql"],
"parser": "@graphql-eslint/eslint-plugin",
"plugins": ["@graphql-eslint"],
"parserOptions": {
"schema": "./lib/graphql/schemaV2.graphql"
}
}
]
}