UNPKG

4.29 kBJavaScriptView Raw
1"use strict";
2
3const camelcase = {
4 allow: ["^UNSAFE_"], // Allows React UNSAFE_ methods
5 ignoreDestructuring: false,
6 properties: "always",
7};
8
9module.exports = {
10 /* eslint-enable sort-keys */
11 ["camelcase"]: camelcase,
12 ["comma-spacing"]: {
13 after: true,
14 before: false
15 },
16 ["indent"]: {
17 ArrayExpression: 1,
18 CallExpression: {
19 arguments: 1
20 },
21 FunctionDeclaration: {
22 body: 1,
23 parameters: 1
24 },
25 FunctionExpression: {
26 body: 1,
27 parameters: 1
28 },
29 MemberExpression: 1,
30 ObjectExpression: 1,
31 SwitchCase: 1,
32 VariableDeclarator: 1,
33 // JSX nodes are handled by react/jsx-indent and should be excluded from this rule
34 // See https://github.com/yannickcr/eslint-plugin-react/issues/1679#issuecomment-363908562
35 ignoredNodes: [
36 "JSXElement",
37 "JSXElement > *",
38 "JSXAttribute",
39 "JSXIdentifier",
40 "JSXNamespacedName",
41 "JSXMemberExpression",
42 "JSXSpreadAttribute",
43 "JSXExpressionContainer",
44 "JSXOpeningElement",
45 "JSXClosingElement",
46 "JSXText",
47 "JSXEmptyExpression",
48 "JSXSpreadChild"
49 ],
50 outerIIFEBody: 1
51 },
52 ["max-lines"]: {
53 max: 700,
54 skipBlankLines: true,
55 skipComments: true
56 },
57 ["no-unused-expressions"]: {
58 allowShortCircuit: true,
59 allowTernary: true
60 },
61 ["no-unused-vars"]: {
62 args: "none",
63 caughtErrors: "none",
64 ignoreRestSiblings: true,
65 vars: "all"
66 },
67 ["quotes"]: {
68 avoidEscape: true
69 },
70 ["space-before-function-paren"]: {
71 anonymous: "always",
72 named: "never"
73 },
74 ["@typescript-eslint/ban-types"]: {
75 types: {
76 // Default options taken from https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/src/rules/ban-types.ts
77 String: {
78 message: "Use string instead",
79 fixWith: "string"
80 },
81 Boolean: {
82 message: "Use boolean instead",
83 fixWith: "boolean"
84 },
85 Number: {
86 message: "Use number instead",
87 fixWith: "number"
88 },
89 Object: {
90 message: "Use Record<string, unknown> instead",
91 fixWith: "Record<string, unknown>"
92 },
93 Symbol: {
94 message: "Use symbol instead",
95 fixWith: "symbol"
96 }
97 }
98 },
99 ["@typescript-eslint/camelcase"]: {
100 ...camelcase,
101 genericType: "always"
102 },
103 ["@typescript-eslint/naming-convention"]: (() => {
104 const options = {
105 default: {
106 format: ["camelCase", "PascalCase", "UPPER_CASE"],
107 leadingUnderscore: "allow",
108 selector: "default",
109 trailingUnderscore: "allow"
110 },
111 function: {
112 format: ["camelCase"],
113 selector: "function"
114 },
115 parameter: {
116 filter: {
117 match: false,
118 regex: "^_+$"
119 },
120 format: ["camelCase", "PascalCase"],
121 selector: "parameter"
122 },
123 method: {
124 filter: {
125 // Allow React's UNSAFE_ prefix
126 match: false,
127 regex: "^UNSAFE_",
128 },
129 format: [
130 "camelCase",
131 ],
132 selector: "method",
133 },
134 typeLike: {
135 format: ["PascalCase"],
136 selector: "typeLike",
137 },
138 enumMember: {
139 format: ["PascalCase"],
140 selector: "enumMember",
141 },
142 };
143
144 options.defaultRules = Object.values(options);
145
146 options.ignoreProperties = {
147 selector: "property",
148 format: null,
149 };
150
151 return options;
152 })()
153 /* eslint-disable sort-keys */
154};