Skip to content

Commit a5f209e

Browse files
committed
Add dev deps and scripts from gatsby monorepo root
1 parent 41f687b commit a5f209e

File tree

5 files changed

+304
-5
lines changed

5 files changed

+304
-5
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*.js
2+
!.*.js
3+
!index.js

.eslintrc.js

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
module.exports = {
2+
parser: `@babel/eslint-parser`,
3+
extends: [
4+
`google`,
5+
`eslint:recommended`,
6+
`plugin:react/recommended`,
7+
`prettier`,
8+
],
9+
plugins: [`prettier`, `react`, `filenames`, `@babel`],
10+
parserOptions: {
11+
ecmaVersion: 2016,
12+
sourceType: `module`,
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
babelOptions: {
17+
configFile: `./.babelrc`,
18+
},
19+
},
20+
env: {
21+
browser: true,
22+
es6: true,
23+
node: true,
24+
jest: true,
25+
},
26+
globals: {
27+
before: true,
28+
after: true,
29+
spyOn: true,
30+
// These should be in scope but for some reason eslint can't see them
31+
NodeJS: true,
32+
JSX: true,
33+
NodeRequire: true,
34+
TimerHandler: true,
35+
__PATH_PREFIX__: true,
36+
__BASE_PATH__: true,
37+
__ASSET_PREFIX__: true,
38+
_CFLAGS_: true,
39+
},
40+
rules: {
41+
"@babel/no-unused-expressions": [
42+
`error`,
43+
{
44+
allowTaggedTemplates: true,
45+
},
46+
],
47+
"no-unused-expressions": `off`,
48+
"@babel/no-invalid-this": `error`,
49+
"no-invalid-this": `off`,
50+
"arrow-body-style": [
51+
`error`,
52+
`as-needed`,
53+
{ requireReturnForObjectLiteral: true },
54+
],
55+
"new-cap": `off`,
56+
"no-unused-vars": [
57+
`warn`,
58+
{
59+
varsIgnorePattern: `^_`,
60+
argsIgnorePattern: `^_`,
61+
ignoreRestSiblings: true,
62+
},
63+
],
64+
"consistent-return": [`error`],
65+
"filenames/match-regex": [`error`, `^[a-z-\\d\\.]+$`, true],
66+
"no-console": `off`,
67+
"no-inner-declarations": `off`,
68+
"prettier/prettier": `error`,
69+
quotes: [`error`, `backtick`],
70+
"react/display-name": `off`,
71+
"react/jsx-key": `warn`,
72+
"react/no-unescaped-entities": `off`,
73+
"react/prop-types": `off`,
74+
"require-jsdoc": `off`,
75+
"valid-jsdoc": `off`,
76+
"prefer-promise-reject-errors": `warn`,
77+
"no-prototype-builtins": `warn`,
78+
"guard-for-in": `warn`,
79+
"spaced-comment": [
80+
`error`,
81+
`always`,
82+
{ markers: [`/`], exceptions: [`*`, `+`] },
83+
],
84+
camelcase: [
85+
`error`,
86+
{
87+
properties: `never`,
88+
ignoreDestructuring: true,
89+
allow: [`^unstable_`],
90+
},
91+
],
92+
},
93+
overrides: [
94+
{
95+
files: [
96+
`packages/**/gatsby-browser.js`,
97+
`packages/gatsby/cache-dir/**/*`,
98+
],
99+
env: {
100+
browser: true,
101+
},
102+
globals: {
103+
___loader: false,
104+
___emitter: false,
105+
},
106+
},
107+
{
108+
files: [`**/cypress/integration/**/*`, `**/cypress/support/**/*`],
109+
globals: {
110+
cy: false,
111+
Cypress: false,
112+
},
113+
},
114+
{
115+
files: [`*.ts`, `*.tsx`],
116+
parser: `@typescript-eslint/parser`,
117+
plugins: [`@typescript-eslint/eslint-plugin`],
118+
extends: [`plugin:@typescript-eslint/recommended`],
119+
rules: {
120+
// We should absolutely avoid using ts-ignore, but it's not always possible.
121+
// particular when a dependencies types are incorrect.
122+
"@typescript-eslint/ban-ts-comment": [
123+
`warn`,
124+
{ "ts-ignore": `allow-with-description` },
125+
],
126+
// This rule is great. It helps us not throw on types for areas that are
127+
// easily inferrable. However we have a desire to have all function inputs
128+
// and outputs declaratively typed. So this let's us ignore the parameters
129+
// inferrable lint.
130+
"@typescript-eslint/no-inferrable-types": [
131+
`error`,
132+
{ ignoreParameters: true },
133+
],
134+
"@typescript-eslint/ban-types": [
135+
`error`,
136+
{
137+
extendDefaults: true,
138+
types: {
139+
"{}": {
140+
fixWith: `Record<string, unknown>`,
141+
},
142+
object: {
143+
fixWith: `Record<string, unknown>`,
144+
},
145+
},
146+
},
147+
],
148+
camelcase: `off`,
149+
// TODO: These rules allow a lot of stuff and don't really enforce. If we want to apply our styleguide, we'd need to fix a lot of stuff
150+
"@typescript-eslint/naming-convention": [
151+
`error`,
152+
{
153+
selector: `default`,
154+
format: [`camelCase`],
155+
},
156+
{
157+
selector: `variable`,
158+
format: [`camelCase`, `UPPER_CASE`, `PascalCase`],
159+
leadingUnderscore: `allowSingleOrDouble`,
160+
trailingUnderscore: `allowSingleOrDouble`,
161+
},
162+
{
163+
selector: `function`,
164+
format: [`camelCase`, `PascalCase`],
165+
leadingUnderscore: `allow`,
166+
},
167+
{
168+
selector: `parameter`,
169+
format: [`camelCase`, `PascalCase`, `snake_case`],
170+
leadingUnderscore: `allowSingleOrDouble`,
171+
},
172+
{
173+
selector: `enumMember`,
174+
format: [`camelCase`, `UPPER_CASE`, `PascalCase`],
175+
},
176+
{
177+
selector: `typeLike`,
178+
format: [`PascalCase`],
179+
},
180+
{
181+
selector: `typeAlias`,
182+
format: [`camelCase`, `PascalCase`],
183+
},
184+
{
185+
selector: `property`,
186+
format: [`PascalCase`, `UPPER_CASE`, `camelCase`, `snake_case`],
187+
leadingUnderscore: `allowSingleOrDouble`,
188+
},
189+
{
190+
selector: `objectLiteralProperty`,
191+
format: [`PascalCase`, `UPPER_CASE`, `camelCase`, `snake_case`],
192+
leadingUnderscore: `allowSingleOrDouble`,
193+
trailingUnderscore: `allowSingleOrDouble`,
194+
},
195+
{
196+
selector: `enum`,
197+
format: [`PascalCase`, `UPPER_CASE`],
198+
},
199+
{
200+
selector: `method`,
201+
format: [`PascalCase`, `camelCase`],
202+
leadingUnderscore: `allowSingleOrDouble`,
203+
},
204+
{
205+
selector: `interface`,
206+
format: [`PascalCase`],
207+
prefix: [`I`],
208+
},
209+
],
210+
// This rule tries to prevent using `require()`. However in node code,
211+
// there are times where this makes sense. And it specifically is causing
212+
// problems in our tests where we often want this functionality for module
213+
// mocking. At this point it's easier to have it off and just encourage
214+
// using top-level imports via code reviews.
215+
"@typescript-eslint/no-var-requires": `off`,
216+
"@typescript-eslint/no-extra-semi": `off`,
217+
// This rule ensures that typescript types do not have semicolons
218+
// at the end of their lines, since our prettier setup is to have no semicolons
219+
// e.g.,
220+
// interface Foo {
221+
// - baz: string;
222+
// + baz: string
223+
// }
224+
"@typescript-eslint/member-delimiter-style": [
225+
`error`,
226+
{
227+
multiline: {
228+
delimiter: `none`,
229+
},
230+
},
231+
],
232+
"@typescript-eslint/no-empty-function": `off`,
233+
// This ensures that we always type the return type of functions
234+
// a high level focus of our TS setup is typing fn inputs and outputs.
235+
"@typescript-eslint/explicit-function-return-type": `error`,
236+
// This forces us to use interfaces over types aliases for object definitions.
237+
// Type is still useful for opaque types
238+
// e.g.,
239+
// type UUID = string
240+
"@typescript-eslint/consistent-type-definitions": [
241+
`error`,
242+
`interface`,
243+
],
244+
"@typescript-eslint/no-use-before-define": [
245+
`error`,
246+
{ functions: false },
247+
],
248+
// Allows us to write unions like `type Foo = "baz" | "bar"`
249+
// otherwise eslint will want to switch the strings to backticks,
250+
// which then crashes the ts compiler
251+
quotes: `off`,
252+
"@typescript-eslint/quotes": [
253+
2,
254+
`backtick`,
255+
{
256+
avoidEscape: true,
257+
},
258+
],
259+
260+
"@typescript-eslint/array-type": [`error`, { default: `generic` }],
261+
},
262+
},
263+
],
264+
settings: {
265+
react: {
266+
version: `16.9.0`,
267+
},
268+
},
269+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/*.js
2+
!.*.js
23
!index.js
34
yarn.lock
5+
node_modules

.prettierrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
arrowParens: `avoid`,
3+
semi: false,
4+
}

package.json

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"version": "3.13.0-next.0",
55
"author": "Kyle Mathews <[email protected]>",
66
"bugs": {
7-
"url": "https://github.com/gatsbyjs/gatsby/issues"
7+
"url": "https://github.com/netlify/gatsby-plugin-netlify/issues"
88
},
99
"contributors": [
1010
{
@@ -22,9 +22,25 @@
2222
"devDependencies": {
2323
"@babel/cli": "^7.14.8",
2424
"@babel/core": "^7.14.8",
25+
"@babel/eslint-parser": "^7.14.0",
26+
"@babel/eslint-plugin": "^7.14.0",
27+
"@typescript-eslint/eslint-plugin": "^4.28.1",
28+
"@typescript-eslint/parser": "^4.28.1",
2529
"babel-preset-gatsby-package": "^1.13.0-next.0",
2630
"cross-env": "^7.0.3",
27-
"gatsby-plugin-utils": "^1.13.0-next.0"
31+
"eslint": "^7.32.0",
32+
"eslint-config-google": "^0.14.0",
33+
"eslint-config-prettier": "^8.3.0",
34+
"eslint-plugin-filenames": "^1.3.2",
35+
"eslint-plugin-import": "^2.23.4",
36+
"eslint-plugin-jsx-a11y": "^6.4.1",
37+
"eslint-plugin-prettier": "^3.4.0",
38+
"eslint-plugin-react": "^7.24.0",
39+
"gatsby": "^3.13.0-next.3",
40+
"gatsby-plugin-utils": "^1.13.0-next.0",
41+
"jest": "^27.0.6",
42+
"prettier": "^2.3.2",
43+
"typescript": "^4.3.5"
2844
},
2945
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-netlify#readme",
3046
"keywords": [
@@ -36,16 +52,21 @@
3652
"license": "MIT",
3753
"main": "index.js",
3854
"peerDependencies": {
39-
"gatsby": "^3.0.0-next.0"
55+
"gatsby": "^3.0.0"
4056
},
4157
"repository": {
4258
"type": "git",
43-
"url": "https://github.com/gatsbyjs/gatsby.git",
44-
"directory": "packages/gatsby-plugin-netlify"
59+
"url": "https://github.com/netlify/gatsby-plugin-netlify.git"
4560
},
4661
"scripts": {
4762
"build": "babel src --out-dir . --ignore \"**/__tests__\"",
4863
"prepare": "cross-env NODE_ENV=production npm run build",
64+
"format": "npm run format:code && npm run format:other",
65+
"format:code": "npm run lint -- --fix",
66+
"format:other": "npm run prettier -- --write",
67+
"lint": "eslint --ext .js,.jsx,.ts,.tsx .",
68+
"prettier": "prettier \"**/*.{md,css,scss,yaml,yml}\"",
69+
"test": "jest",
4970
"watch": "babel -w src --out-dir . --ignore \"**/__tests__\""
5071
},
5172
"engines": {

0 commit comments

Comments
 (0)