Skip to content

Commit

Permalink
chore: add devDependencies & configure tailwind.css, husky, lint-stag…
Browse files Browse the repository at this point in the history
…ed, eslint & prettier
  • Loading branch information
wisnie committed Oct 8, 2022
1 parent e7e5330 commit 8f4dcd3
Show file tree
Hide file tree
Showing 17 changed files with 13,431 additions and 2,208 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.next
out
package-lock.json
node_modules
.swc
40 changes: 39 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
{
"extends": "next/core-web-vitals"
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": { "sourceType": "module", "project": ["./tsconfig.json"] },
// eslint-react, eslint-react-hooks, eslint-import and eslint-jsx-a11y are installed
// with next/core-web-vitals
"extends": [
// next/core-web-vitals as first, bcs it turns of some strict rules
// of jsx-a11y/recommended set
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended",
// can be removed if linting is slow
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:css-modules/recommended",
"plugin:jsx-a11y/recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "css-modules"],
"rules": {
"react-hooks/exhaustive-deps": "error",
"react/display-name": "error",
"react/jsx-curly-brace-presence": ["error", "never"]
},
"ignorePatterns": [
"src/**/*.test.ts",
"tailwind.config.js",
"postcss.config.js",
"jest.config.js",
"next.config.js",
"commitlint.config.js"
],
"settings": {
"jsx-a11y": {
"components": {
"Input": "input",
"Button": "button",
"Image": "img"
}
}
}
}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit ""
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.next
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"arrowParens": "always",
"trailingComma": "all",
"printWidth": 100
}
15 changes: 15 additions & 0 deletions __tests__/Index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render, screen } from '@testing-library/react';
import Home from '../pages/index';
import '@testing-library/jest-dom';

describe('Home', () => {
it('renders a heading', () => {
render(<Home />);

const heading = screen.getByRole('heading', {
name: /welcome to next\.js!/i,
});

expect(heading).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
19 changes: 19 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const nextJest = require('next/jest');

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
});

// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const customJestConfig = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig);
Loading

0 comments on commit 8f4dcd3

Please sign in to comment.