Skip to content

Commit

Permalink
refactor: moving to npm-shareable-configs v2 (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp authored Feb 22, 2023
1 parent 20b4d64 commit 43bdf17
Show file tree
Hide file tree
Showing 59 changed files with 3,777 additions and 4,944 deletions.
3 changes: 2 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"version": true,
"tag": true
},
"commit": true,
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "master",
Expand Down
7 changes: 0 additions & 7 deletions .changeset/small-pigs-remember.md

This file was deleted.

1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ NEXT_PUBLIC_FACEBOOK_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# Authentification
NEXTAUTH_URL=${APP_URL}
NEXTAUTH_SECRET=g14lN7OMPxxXxxxXxXXx/XXXXXXXXXXXXXXXXXXXXXX=
13 changes: 0 additions & 13 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
#!/usr/bin/env sh
. "$(dirname "$0")/_/husky.sh"

#echo '🏗️👷 Styling your project before committing👷‍♂️🏗️'
#echo 'please be patient, this may take a while...'
#
## Check ESLint Standards
#docker-compose exec -T -e FORCE_COLOR=1 app pnpm lint ||
# (
# echo '🔨❌ Yoo, you have a problem in your code. Check linter 🔨❌
# Run pnpm lint, add changes and try commit again.'
# false
# )
#
#echo '🎉 No error found: committing this now.... ✨🚀🏄‍♂️🍻'

pnpm lint-staged --verbose --concurrent false
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ engine-strict=false

### https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31#recommended-npmrc
# https://pnpm.io/next/npmrc#strict-peer-dependencies
strict-peer-dependencies=false
strict-peer-dependencies=true

# https://pnpm.io/npmrc#auto-install-peers
auto-install-peers=true
Expand Down
8 changes: 4 additions & 4 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

const { getPrettierConfig } = require('@wayofdev/eslint-config-custom/helpers');
const { getPrettierConfig } = require('@wayofdev/eslint-config-bases/helpers')

const { overrides = [], ...prettierConfig } = getPrettierConfig();
const { overrides = [], ...prettierConfig } = getPrettierConfig()

/**
* @type {import('prettier').Config}
Expand All @@ -21,6 +21,6 @@ const config = {
},
],
],
};
}

module.exports = config;
module.exports = config
5 changes: 5 additions & 0 deletions .secretlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pnpm-store
packages/**/node_modules
packages/**/.turbo
apps/**/node_modules
apps/**/.turbo
4 changes: 2 additions & 2 deletions .secretlintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
...require("@wayofdev/secretlint-config"),
};
...require('@wayofdev/secretlint-config'),
}
22 changes: 0 additions & 22 deletions .stylelintrc.js

This file was deleted.

32 changes: 25 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ update: ## Run pnpm to packages to their latest version based on the specified r
$(NPM_RUNNER) update
.PHONY: update

build: ## Build all apps inside monorepo
build: ## Build all apps and packages inside monorepo
$(NPM_RUNNER) run build
.PHONY: build

purge: down ## Stops container and deletes node modules and temporary files
rm -rf .pnpm-store node_modules && \
rm -rf **/node_modules pnpm-lock.yaml **/.turbo **/.next
find . | grep /node_modules$ | grep -v /node_modules/ | xargs rm -fR
find . | grep /.turbo$ | grep -v /.turbo/ | xargs rm -fR
find . | grep /.next$ | grep -v /.next/ | xargs rm -fR
rm -rf .pnpm-store pnpm-lock.yaml
.PHONY: purge

deps-check: ## Check for outdated dependencies
Expand Down Expand Up @@ -176,12 +178,12 @@ lint: ## Run lint task to fix issues
.PHONY: lint

lint-staged: ## Lint staged files
$(NPM_COMPOSE_RUNNER) lint-staged
$(NPM_COMPOSE_RUNNER) lint:staged
.PHONY: lint-staged

commitlint: ## Run commitlint to check commit message
lint-commits: ## Run commitlint to check commit message
$(DOCKER_COMPOSE) exec -T -e FORCE_COLOR=1 app npx --no --commitlint --edit $(1)
.PHONY: commitlint
.PHONY: lint-commits

lint-md: ## Lint markdown files
$(NPM_COMPOSE_RUNNER) lint:md
Expand All @@ -203,8 +205,20 @@ lint-secrets: ## Check if there are any missed secret credentials in code
$(NPM_COMPOSE_RUNNER) lint:secrets
.PHONY: lint-secrets

lint-browsers: ## Check if there are any missed secret credentials in code
$(NPM_COMPOSE_RUNNER) lint:browsers
.PHONY: lint-browsers

lint-yaml: ## Lints yaml files inside project
yamllint .
.PHONY: lint-yaml

lint-actions: ## Lint github actions using actionlint
$(BUILDER) actionlint -color
.PHONY: lint-actions

test: ## Run unit tests
$(NPM_COMPOSE_RUNNER) test
$(NPM_COMPOSE_RUNNER) test:unit
.PHONY: test

format: ## Run prettier formatting
Expand All @@ -231,6 +245,10 @@ cs-version:
.PHONY: version

cs-release: ## Publish new version to npm
npx changeset release
.PHONY: release

cs-publish: ## Run build, lint tasks and then publish new version to npm
npx changeset publish
.PHONY: release

Expand Down
22 changes: 11 additions & 11 deletions apps/docs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

// Workaround for https://github.com/eslint/eslint/issues/3458 (re-export of @rushstack/eslint-patch)
require('@wayofdev/eslint-config-custom/patch/modern-module-resolution')
require('@wayofdev/eslint-config-bases/patch/modern-module-resolution')

const { getDefaultIgnorePatterns } = require('@wayofdev/eslint-config-custom/helpers')
const { getDefaultIgnorePatterns } = require('@wayofdev/eslint-config-bases/helpers')

module.exports = {
root: true,
Expand All @@ -17,18 +17,18 @@ module.exports = {
},
ignorePatterns: [...getDefaultIgnorePatterns(), '.next', '.out'],
extends: [
'@wayofdev/eslint-config-custom/typescript',
'@wayofdev/eslint-config-custom/regexp',
'@wayofdev/eslint-config-custom/sonar',
'@wayofdev/eslint-config-custom/jest',
'@wayofdev/eslint-config-custom/rtl',
'@wayofdev/eslint-config-custom/react',
'@wayofdev/eslint-config-custom/tailwind',
'@wayofdev/eslint-config-custom/mdx',
'@wayofdev/eslint-config-bases/typescript',
'@wayofdev/eslint-config-bases/regexp',
'@wayofdev/eslint-config-bases/sonar',
'@wayofdev/eslint-config-bases/jest',
'@wayofdev/eslint-config-bases/rtl',
'@wayofdev/eslint-config-bases/react',
'@wayofdev/eslint-config-bases/tailwind',
'@wayofdev/eslint-config-bases/mdx',
// Add specific rules for nextjs
'plugin:@next/next/core-web-vitals',
// Apply prettier and disable incompatible rules
'@wayofdev/eslint-config-custom/prettier',
'@wayofdev/eslint-config-bases/prettier-plugin',
],
rules: {
// https://github.com/vercel/next.js/discussions/16832
Expand Down
42 changes: 42 additions & 0 deletions apps/docs/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check

/**
* This files overrides the base lint-staged.config.js present in the root directory.
* It allows to run eslint based the package specific requirements.
* {@link https://github.com/okonet/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo}
* {@link https://github.com/belgattitude/nextjs-monorepo-example/blob/main/docs/about-lint-staged.md}
*/

const {
getEslintFixCmd,
jsonRules,
secretsRules,
mdRules,
yamlRules,
htmlRules,
} = require('@wayofdev/lint-staged-config')

/**
* @typedef {Record<string, (filenames: string[]) => string | string[] | Promise<string | string[]>>} LintRule
*/
const rules = {
'**/*.{js,jsx,ts,tsx}': (/** @type {any} */ filenames) => {
return getEslintFixCmd({
cwd: __dirname,
fix: true,
cache: true,
// when autofixing staged-files a good tip is to disable react-hooks/exhaustive-deps, cause
// a change here can potentially break things without proper visibility.
rules: ['react-hooks/exhaustive-deps: off'],
maxWarnings: 25,
files: filenames,
})
},
...jsonRules,
...secretsRules,
...mdRules,
...yamlRules,
...htmlRules,
}

module.exports = rules
15 changes: 7 additions & 8 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "docs",
"name": "@wayofdev/docs",
"version": "1.0.0",
"private": true,
"scripts": {
Expand All @@ -12,7 +12,7 @@
"start": "next start"
},
"dependencies": {
"@vercel/analytics": "latest",
"@vercel/analytics": "^0.1.10",
"@wayofdev/ui": "workspace:*",
"next": "^13.1.6",
"nextra": "^2.2.14",
Expand All @@ -21,13 +21,12 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.11.18",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@wayofdev/browserslist-config": "^1.1.0",
"@wayofdev/eslint-config-custom": "workspace:*",
"@types/node": "^18.14.0",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@wayofdev/eslint-config-bases": "^2.0.2",
"es-check": "^7.1.0",
"eslint": "^8.33.0",
"eslint": "^8.34.0",
"sharp": "^0.31.3",
"typescript": "^4.9.5"
}
Expand Down
25 changes: 13 additions & 12 deletions apps/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
*/

// Workaround for https://github.com/eslint/eslint/issues/3458 (re-export of @rushstack/eslint-patch)
require('@wayofdev/eslint-config-custom/patch/modern-module-resolution')
require('@wayofdev/eslint-config-bases/patch/modern-module-resolution')

const { getDefaultIgnorePatterns } = require('@wayofdev/eslint-config-custom/helpers')
const { getDefaultIgnorePatterns } = require('@wayofdev/eslint-config-bases/helpers')

module.exports = {
root: true,
Expand All @@ -17,19 +17,20 @@ module.exports = {
},
ignorePatterns: [...getDefaultIgnorePatterns(), '.next', '.out', '/storybook-static'],
extends: [
'@wayofdev/eslint-config-custom/typescript',
'@wayofdev/eslint-config-custom/regexp',
'@wayofdev/eslint-config-custom/sonar',
'@wayofdev/eslint-config-custom/jest',
'@wayofdev/eslint-config-custom/rtl',
'@wayofdev/eslint-config-custom/storybook',
'@wayofdev/eslint-config-custom/react',
'@wayofdev/eslint-config-custom/tailwind',
'@wayofdev/eslint-config-custom/mdx',
'@wayofdev/eslint-config-bases/typescript',
'@wayofdev/eslint-config-bases/regexp',
'@wayofdev/eslint-config-bases/sonar',
'@wayofdev/eslint-config-bases/jest',
'@wayofdev/eslint-config-bases/rtl',
'@wayofdev/eslint-config-bases/storybook',
'@wayofdev/eslint-config-bases/react',
'@wayofdev/eslint-config-bases/react-query',
'@wayofdev/eslint-config-bases/tailwind',
'@wayofdev/eslint-config-bases/mdx',
// Add specific rules for nextjs
'plugin:@next/next/core-web-vitals',
// Apply prettier and disable incompatible rules
'@wayofdev/eslint-config-custom/prettier',
'@wayofdev/eslint-config-bases/prettier-plugin',
],
rules: {
// https://github.com/vercel/next.js/discussions/16832
Expand Down
3 changes: 2 additions & 1 deletion apps/web/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ const config = {
'<rootDir>/**/*.{ts,tsx,js,jsx}',
'!**/*.test.{js,ts}',
'!**/__mock__/*',
'!**/stories/*',
'!**/stories/*.tsx',
],
transformIgnorePatterns: ['/node_modules/(?!@vercel/analytics)/'],
}

module.exports = config
42 changes: 42 additions & 0 deletions apps/web/lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check

/**
* This files overrides the base lint-staged.config.js present in the root directory.
* It allows to run eslint based the package specific requirements.
* {@link https://github.com/okonet/lint-staged#how-to-use-lint-staged-in-a-multi-package-monorepo}
* {@link https://github.com/belgattitude/nextjs-monorepo-example/blob/main/docs/about-lint-staged.md}
*/

const {
getEslintFixCmd,
jsonRules,
secretsRules,
mdRules,
yamlRules,
htmlRules,
} = require('@wayofdev/lint-staged-config')

/**
* @typedef {Record<string, (filenames: string[]) => string | string[] | Promise<string | string[]>>} LintRule
*/
const rules = {
'**/*.{js,jsx,ts,tsx}': (/** @type {any} */ filenames) => {
return getEslintFixCmd({
cwd: __dirname,
fix: true,
cache: true,
// when autofixing staged-files a good tip is to disable react-hooks/exhaustive-deps, cause
// a change here can potentially break things without proper visibility.
rules: ['react-hooks/exhaustive-deps: off'],
maxWarnings: 25,
files: filenames,
})
},
...jsonRules,
...secretsRules,
...mdRules,
...yamlRules,
...htmlRules,
}

module.exports = rules
Loading

2 comments on commit 43bdf17

@vercel
Copy link

@vercel vercel bot commented on 43bdf17 Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 43bdf17 Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

next-starter-tpl-web – ./apps/web

Please sign in to comment.