Skip to content

Commit c7774c9

Browse files
upgrade packages and dependencies
1 parent f88a162 commit c7774c9

20 files changed

+818
-819
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
APP_NAME="Starter Project"
1+
NEXT_PUBLIC_APP_NAME="Starter Project"

.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
APP_NAME="Starter Project"
1+
NEXT_PUBLIC_APP_NAME="Starter Project"

.eslintrc

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22
"parser": "@typescript-eslint/parser",
33
"extends": [
44
"next",
5-
"plugin:react/recommended",
5+
"next/core-web-vitals",
66
"airbnb",
77
"airbnb-typescript",
8-
"plugin:jsx-a11y/recommended",
98
"plugin:sonarjs/recommended",
10-
"plugin:react-hooks/recommended",
11-
"plugin:prettier/recommended"
9+
"prettier"
1210
],
1311
"plugins": [
1412
"@typescript-eslint",
1513
"jest",
16-
"react"
14+
"simple-import-sort",
15+
"unused-imports"
1716
],
1817
"env": {
19-
"es6": true,
18+
"es2021": true,
2019
"browser": true,
21-
"jest": true
20+
"jest": true,
21+
"node": true
2222
},
2323
"rules": {
2424
"react/require-default-props": "off",
2525
"import/prefer-default-export": "off",
2626
"react/prop-types": "off",
27-
"import/no-cycle": "off",
2827
"no-multi-assign": "off",
2928
"import/imports-first": [
3029
"error",
@@ -48,6 +47,10 @@
4847
]
4948
}
5049
],
50+
// Multiline indentation: https://stackoverflow.com/a/48906878
51+
"indent": ["error", 2],
52+
"react/jsx-indent": ["error", 2],
53+
"react/jsx-indent-props": ["error", 2],
5154
"quotes": [
5255
2,
5356
"single",
@@ -66,16 +69,37 @@
6669
"ForInStatement"
6770
],
6871
"use-isnan": "error",
69-
"@typescript-eslint/no-unused-vars": [
70-
"error",
72+
"@typescript-eslint/no-unused-vars": "off",
73+
"unused-imports/no-unused-imports": "warn",
74+
"unused-imports/no-unused-vars": [
75+
"warn",
7176
{
72-
"args": "after-used",
73-
"ignoreRestSiblings": true,
7477
"vars": "all",
7578
"varsIgnorePattern": "^_",
79+
"args": "after-used",
7680
"argsIgnorePattern": "^_"
7781
}
7882
],
83+
"simple-import-sort/exports": "warn",
84+
"simple-import-sort/imports": [
85+
"warn",
86+
{
87+
"groups": [
88+
["^node:"],
89+
["^react", "^next"],
90+
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
91+
// & side effect imports
92+
["^@?\\w", "^\\u0000"],
93+
["^.+\\.s?css$"],
94+
// Other imports
95+
["^@/", "^~/"],
96+
// anything not matched in other groups
97+
["^"],
98+
// relative imports - anything that starts with a dot
99+
["^\\."]
100+
]
101+
}
102+
],
79103
"@typescript-eslint/await-thenable": "error",
80104
"@typescript-eslint/no-floating-promises": "error",
81105
"@typescript-eslint/no-misused-new": "error",
@@ -106,7 +130,7 @@
106130
},
107131
"parserOptions": {
108132
// Allows for the parsing of modern ECMAScript features
109-
"ecmaVersion": 2018,
133+
"ecmaVersion": 2021,
110134
// Allows for the use of imports
111135
"sourceType": "module",
112136
// https://blog.geographer.fr/eslint-parser-services, https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ yarn-error.log*
2727

2828
# Environment Variables
2929
.env
30+
.env.local
3031

3132
# Typescript
3233
tsconfig.tsbuildinfo

.lintstagedrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
const path = require('path')
2+
3+
// With `next lint`: https://nextjs.org/docs/basic-features/eslint#lint-staged
4+
const buildEslintCommand = (filenames) =>
5+
`yarn lint:fix --file ${filenames.map((f) => path.relative(process.cwd(), f)).join(' --file ')}`
6+
17
module.exports = {
2-
'*.{js,jsx,ts,tsx}': 'npm run format',
8+
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
39
'*.{ts,tsx}': "bash -c 'npm run typecheck'", // running this via bash https://github.com/okonet/lint-staged/issues/825#issuecomment-727185296
410
}

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
22
"singleQuote": true,
3+
"jsxSingleQuote": true,
4+
"arrowParens": "always",
35
"noSemi": true,
46
"semi": false,
57
"trailingComma": "all",
8+
"tabWidth": 2,
69
"printWidth": 120
710
}

.swcrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

jest.config.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
module.exports = {
2-
preset: 'ts-jest/presets/js-with-ts',
3-
setupFiles: ['<rootDir>/jest.setup.ts'],
4-
moduleNameMapper: {
5-
'^@src/(.*)$': '<rootDir>/src/$1',
6-
},
7-
coveragePathIgnorePatterns: ['/node_modules/'],
8-
transform: {
9-
'^.+\\.[tj]sx?$': [
10-
'ts-jest',
11-
{
12-
tsconfig: '<rootDir>/tsconfig.jest.json',
13-
diagnostics: false,
14-
},
15-
],
16-
},
1+
const nextJest = require('next/jest')
2+
3+
const createJestConfig = nextJest({
4+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
5+
dir: './',
6+
})
7+
8+
// Add any custom config to be passed to Jest
9+
/** @type {import('jest').Config} */
10+
const customJestConfig = {
11+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
1712
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
13+
14+
// if using TypeScript with a baseUrl set to the root directory then you need the snippet below for alias' to work
15+
moduleDirectories: ['node_modules', '<rootDir>/'],
16+
17+
testEnvironment: 'jest-environment-jsdom',
1818
testMatch: ['**/*.(test|spec).(js|jsx|ts|tsx)'],
19-
testEnvironment: 'jsdom',
19+
coveragePathIgnorePatterns: ['/node_modules/'],
20+
/**
21+
* Absolute imports and module path aliases
22+
*/
23+
moduleNameMapper: {
24+
'^@/(.*)$': '<rootDir>/src/$1',
25+
'^~/(.*)$': '<rootDir>/public/$1',
26+
},
2027
}
28+
29+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
30+
module.exports = createJestConfig(customJestConfig)

jest.setup.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Loading `.env.test`: https://github.com/vercel/next.js/discussions/16270#discussioncomment-54198
2-
import next from 'next'
1+
import '@testing-library/jest-dom/extend-expect'
32

4-
next({})
3+
// Allow router mocks.
4+
// eslint-disable-next-line no-undef, global-require
5+
jest.mock('next/router', () => require('next-router-mock'))

next.config.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1+
/** @type {import('next').NextConfig} */
12
module.exports = {
23
poweredByHeader: false,
34
generateEtags: false,
4-
/**
5-
* Environment Variables.
6-
*/
7-
publicRuntimeConfig: {
8-
APP_NAME: process.env.APP_NAME,
9-
},
10-
serverRuntimeConfig: {},
5+
reactStrictMode: true,
6+
swcMinify: true,
117
}

0 commit comments

Comments
 (0)