Skip to content

Instantly share code, notes, and snippets.

@lsmoura
Last active February 10, 2020 18:21
Show Gist options
  • Save lsmoura/a0bf74430f37442a1d803d6854c9e512 to your computer and use it in GitHub Desktop.
Save lsmoura/a0bf74430f37442a1d803d6854c9e512 to your computer and use it in GitHub Desktop.
Init nextjs repo
#!/bin/sh
git init .
yarn init . -y
echo "node_modules/" > .gitignore
echo "coverage/" >> .gitignore
echo ".next" >> .gitignore
echo ".nyc_output" >> .gitignore
echo "public/" >> .gitignore
yarn add core-js@3
yarn add next react react-dom @babel/preset-env @babel/preset-react @babel/core @babel/node @babel/plugin-transform-runtime
yarn add --dev jest @testing-library/react @testing-library/dom @testing-library/jest-dom eslint babel-eslint eslint-plugin-react
yarn add prettier --dev --exact
mkdir pages
cat > babel.config.js <<EOF
module.exports = {
presets:[
'@babel/env',
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-runtime',
],
};
EOF
cat > pages/index.js <<EOF
import React from 'react';
const App = () => {
return <div>Hello World!</div>;
};
export default App;
EOF
cat > pages/index.test.js <<EOF
import React from 'react';
import { render, fireEvent, waitForElement } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import App from './index';
describe('<App />', () => {
it('renders properly', () => {
const { getByText } = render(<App />);
expect(getByText('Hello World!')).toBeInTheDocument();
});
});
EOF
cat > .eslintrc.yaml <<EOF
parser: babel-eslint
parserOptions:
ecmaFeatures:
jsx: true
sourceType: module
env:
es6: true
browser: true
amd: true
node: true
plugins:
- react
rules:
semi: error
no-unused-vars: warn
quote-props:
- warn
- as-needed
comma-dangle:
- warn
- always-multiline
no-undef: error
react/jsx-uses-react: error
EOF
cat > .prettierrc.yaml <<EOF
trailingComma: es5
tabWidth: 2
semi: true
singleQuote: true
jsxBracketSameLine: false
useTabs: false
bracketSpacing: true
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment