Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lint, workspace): Orderliness and break avoiding lint rules, package.json flags #1381

Merged
merged 20 commits into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": "@redwoodjs/eslint-config",
"rules": {
"import/order": [
"error",
{
"newlines-between": "always",
"pathGroupsExcludedImportTypes": [
"react"
],
"pathGroups": [
{
"pattern": "react",
"group": "builtin",
"position": "after"
},
{
"pattern": "@redwoodjs/**",
"group": "external",
"position": "after"
},
{
"pattern": "src/**",
"group": "parent",
"position": "before"
}
],
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
15 changes: 13 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@
"statusBar.background": "#b85833",
"statusBarItem.hoverBackground": "#ce7350",
"statusBar.foreground": "#e7e7e7",
"statusBar.border": "#b85833"
"activityBar.activeBackground": "#ce7350",
"activityBar.activeBorder": "#82dc9b",
"activityBar.background": "#ce7350",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#82dc9b",
"activityBarBadge.foreground": "#15202b",
"titleBar.activeBackground": "#b85833",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#b8583399",
"titleBar.inactiveForeground": "#e7e7e799"
peterp marked this conversation as resolved.
Show resolved Hide resolved
},
"search.exclude": {
"**/dist": true,
"**/node_modules": true,
"**/__fixtures__": true
}
},
"peacock.color": "#b85833"
}
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"scripts": {
"build": "lerna run build:js && ttsc --build --verbose",
"build:clean": "rimraf ./packages/**/dist",
"build:watch": "ttsc --build && lerna run build:watch --parallel",
"test": "lerna run test --stream -- --colors --maxWorkers=4",
"lint": "eslint packages",
"lint:fix": "eslint --fix packages"
},
peterp marked this conversation as resolved.
Show resolved Hide resolved
"private": true,
"license": "MIT",
"npmClient": "yarn",
"useWorkspaces": true,
"workspaces": [
"packages/*"
],
Expand All @@ -15,7 +25,6 @@
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"@babel/runtime-corejs3": "^7.11.2",
"core-js": "3.6.5",
"@testing-library/jest-dom": "5.11.4",
"@testing-library/react": "11.1.0",
"@testing-library/user-event": "^12.0.11",
Expand All @@ -25,28 +34,21 @@
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-remove-code": "^0.0.6",
"bundlesize": "^0.18.0",
"core-js": "3.6.5",
"cp-cli": "^2.0.0",
"cross-env": "^7.0.2",
"jest": "^26.5.3",
"lerna": "^3.20.2",
"msw": "0.21.2",
"nodemon": "^2.0.2",
"rimraf": "^3.0.2",
"ts-node": "^9.0.0",
peterp marked this conversation as resolved.
Show resolved Hide resolved
"ttypescript": "^1.5.12",
"typescript": "^4.0.2",
"typescript-transform-paths": "^2.0.2",
"whatwg-fetch": "3.4.1"
},
"resolutions": {
"@types/react": "16.9.53"
},
"eslintConfig": {
"extends": "@redwoodjs/eslint-config"
},
"scripts": {
"build": "lerna run build:js && tsc --build --verbose",
"build:clean": "rimraf ./packages/**/dist",
"build:watch": "tsc --build && lerna run build:watch --parallel",
"test": "lerna run test --stream -- --colors --maxWorkers=4",
"lint": "eslint packages",
"lint:fix": "eslint --fix packages"
}
}
2 changes: 1 addition & 1 deletion packages/api-server/src/http.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bodyParser from 'body-parser'
import type { Response, Request } from 'express'
import express from 'express'
import morgan from 'morgan'
import bodyParser from 'body-parser'

export interface Lambdas {
[path: string]: any
Expand Down
3 changes: 2 additions & 1 deletion packages/api-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
import path from 'path'
import yargs from 'yargs'

import requireDir from 'require-dir'
import yargs from 'yargs'

import { server, setLambdaFunctions } from './http'
import { requestHandler } from './requestHandlers/awsLambda'
Expand Down
3 changes: 3 additions & 0 deletions packages/api-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src", "ambient.d.ts"],
"references": [{ "path": "../internal" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"build": "yarn build:js && yarn build:types",
"prepublishOnly": "yarn cross-env NODE_ENV=production yarn build",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build:types": "tsc --build --verbose",
"build:types": "ttsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
6 changes: 4 additions & 2 deletions packages/api/src/auth/decoders/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import type { GlobalContext } from 'src/globalContext'
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import { netlify } from './netlify'
import type { GlobalContext } from 'src/globalContext'

import { auth0 } from './auth0'
import { netlify } from './netlify'
const noop = (token: string) => token

const typesToDecoders: Record<SupportedAuthTypes, Function> = {
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { GlobalContext } from 'src/globalContext'
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { SupportedAuthTypes } from '@redwoodjs/auth'

import type { GlobalContext } from 'src/globalContext'

import { decodeToken } from './decoders'

// This is shared by `@redwoodjs/web`
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/functions/authDecoder.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mockedAPIGatewayProxyEvent from './fixtures/apiGatewayProxyEvent.fixture'
import * as auth0Decoder from './../auth/decoders/auth0'
import * as netlifyDecoder from './../auth/decoders/netlify'
import { decodeToken } from './../auth/decoders/index'
import * as netlifyDecoder from './../auth/decoders/netlify'
import mockedAPIGatewayProxyEvent from './fixtures/apiGatewayProxyEvent.fixture'

jest.mock('./../auth/decoders/auth0', () => {
return {
Expand Down
9 changes: 5 additions & 4 deletions packages/api/src/functions/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'
import type { Config, CreateHandlerOptions } from 'apollo-server-lambda'
import type { Context, ContextFunction } from 'apollo-server-core'
import type { GlobalContext } from 'src/globalContext'
import type { AuthContextPayload } from 'src/auth'
import type { Config, CreateHandlerOptions } from 'apollo-server-lambda'
import { ApolloServer } from 'apollo-server-lambda'
import type { APIGatewayProxyEvent, Context as LambdaContext } from 'aws-lambda'

import type { AuthContextPayload } from 'src/auth'
import { getAuthenticationContext } from 'src/auth'
import type { GlobalContext } from 'src/globalContext'
import { setContext } from 'src/globalContext'

export type GetCurrentUser = (
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/makeMergedSchema/makeMergedSchema.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GraphQLResolveInfo } from 'graphql'
import { gql } from 'apollo-server-lambda'
import { GraphQLResolveInfo } from 'graphql'

import { GraphQLTypeWithFields } from '../types'
import { makeMergedSchema } from '../makeMergedSchema/makeMergedSchema'
import { GraphQLTypeWithFields } from '../types'

describe('makeMergedSchema', () => {
// Simulate `importAll`
Expand Down
5 changes: 3 additions & 2 deletions packages/api/src/makeMergedSchema/makeMergedSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import {
IResolvers,
IExecutableSchemaDefinition,
} from 'apollo-server-lambda'
import { mergeTypes } from 'merge-graphql-schemas'
import { GraphQLSchema, GraphQLFieldMap } from 'graphql'
import merge from 'lodash.merge'
import omitBy from 'lodash.omitby'
import { GraphQLSchema, GraphQLFieldMap } from 'graphql'
import { mergeTypes } from 'merge-graphql-schemas'

import { Services, GraphQLTypeWithFields } from 'src/types'

import * as rootSchema from './rootSchema'
Expand Down
10 changes: 5 additions & 5 deletions packages/api/src/makeMergedSchema/rootSchema.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import type { GlobalContext } from 'src/globalContext'
import { PrismaClient } from '@prisma/client'
import gql from 'graphql-tag'
import {
DateResolver,
TimeResolver,
DateTimeResolver,
JSONResolver,
JSONObjectResolver,
} from 'graphql-scalars'

import gql from 'graphql-tag'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore - not inside the <rootDir>
import apiPackageJson from 'src/../package.json'

import type { GlobalContext } from 'src/globalContext'

/**
* This adds scalar types for dealing with Date, Time, DateTime, and JSON.
* This also adds a root Query type which is needed to start the GraphQL server on a fresh install.
Expand Down Expand Up @@ -52,7 +52,7 @@ export const resolvers: Resolvers = {
JSONObject: JSONObjectResolver,
Query: {
redwood: () => ({
version: apiPackageJson.version,
version: apiPackageJson.version as string, // cast because TS will forget
prismaVersion: () => PrismaClient.prismaVersion,
currentUser: (_args: any, context: GlobalContext) => {
return context?.currentUser
Expand Down
7 changes: 5 additions & 2 deletions packages/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src", "src/../package.json"],
"references": [
{ "path": "../auth", },
{ "path": "../dev-server", }
{ "path": "../auth" },
{ "path": "../dev-server" }
]
}
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"build": "yarn build:js && yarn build:types",
"prepublishOnly": "yarn cross-env NODE_ENV=production yarn build",
"build:js": "babel src -d dist --extensions \".js,.ts,.tsx\"",
"build:types": "tsc --build --verbose",
"build:types": "ttsc --build --verbose",
"build:watch": "nodemon --watch src --ext \"js,ts,tsx\" --ignore dist --exec \"yarn build\"",
"test": "jest",
"test:watch": "yarn test --watch"
Expand Down
6 changes: 3 additions & 3 deletions packages/auth/src/__tests__/AuthProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ require('whatwg-fetch')

import { render, screen, fireEvent, waitFor } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import { setupServer } from 'msw/node'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'

import { useAuth } from '../useAuth'
import { AuthProvider } from '../AuthProvider'
import type { AuthClient } from '../authClients'
import { AuthProvider } from '../AuthProvider'
import { useAuth } from '../useAuth'

let CURRENT_USER_DATA = {
name: 'Peter Pistorius',
Expand Down
24 changes: 14 additions & 10 deletions packages/auth/src/authClients/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { NetlifyIdentity } from './netlify'
import type { Auth0, Auth0User } from './auth0'
import { auth0 } from './auth0'
import type { Custom } from './custom'
import { custom } from './custom'
import type { Firebase } from './firebase'
import { firebase } from './firebase'
import type { GoTrue, GoTrueUser } from './goTrue'
import { goTrue } from './goTrue'
import type { MagicLink, MagicUser } from './magicLink'
import type { Firebase } from './firebase'
import { magicLink } from './magicLink'
import type { NetlifyIdentity } from './netlify'
peterp marked this conversation as resolved.
Show resolved Hide resolved
import { netlify } from './netlify'
import type { Supabase, SupabaseUser } from './supabase'
import type { Custom } from './custom'
//
import { netlify } from './netlify'
import { auth0 } from './auth0'
import { goTrue } from './goTrue'
import { magicLink } from './magicLink'
import { firebase } from './firebase'
import { supabase } from './supabase'
import { custom } from './custom'

const typesToClients = {
netlify,
Expand Down Expand Up @@ -40,7 +40,11 @@ export type { Auth0User }
export type { GoTrueUser }
export type { MagicUser }
export type { SupabaseUser }
export type SupportedUserMetadata = Auth0User | GoTrueUser | MagicUser | SupabaseUser
export type SupportedUserMetadata =
| Auth0User
| GoTrueUser
| MagicUser
| SupabaseUser

export interface AuthClient {
restoreAuthState?(): void | Promise<any>
Expand Down
3 changes: 3 additions & 0 deletions packages/auth/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"rootDir": "src",
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"outDir": "dist",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["src"],
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Listr from 'listr'
import VerboseRenderer from 'listr-verbose-renderer'
import terminalLink from 'terminal-link'

import { handler as generatePrismaClient } from 'src/commands/dbCommands/generate'
import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
import { handler as generatePrismaClient } from 'src/commands/dbCommands/generate'

export const command = 'build [side..]'
export const description = 'Build for production'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/dataMigrate/install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path'

import fs from 'fs-extra'
import execa from 'execa'
import fs from 'fs-extra'
import Listr from 'listr'
import terminalLink from 'terminal-link'

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/dataMigrate/up.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from 'path'
import fs from 'fs'
import path from 'path'

import Listr from 'listr'
import terminalLink from 'terminal-link'
import VerboseRenderer from 'listr-verbose-renderer'
import terminalLink from 'terminal-link'

import { getPaths } from 'src/lib'
import c from 'src/lib/colors'
Expand Down
Loading