Skip to content

Commit

Permalink
feat: add eslint and prettier
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <github@iverly.net>
  • Loading branch information
iverly committed Oct 23, 2023
1 parent 53a724f commit 45103a2
Show file tree
Hide file tree
Showing 16 changed files with 2,753 additions and 126 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.next/
109 changes: 109 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
reportUnusedDisableDirectives: true,
ignorePatterns: ['next-env.d.ts'],
env: {
node: true,
},
overrides: [
// Rules for all files
{
files: '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier',
],
plugins: ['import', 'unicorn'],
rules: {
'comma-dangle': ['error', 'always-multiline'],
'prefer-object-has-own': 'error',
'logical-assignment-operators': [
'error',
'always',
{ enforceForIfStatements: true },
],
'no-else-return': ['error', { allowElseIf: false }],
'no-lonely-if': 'error',
'prefer-destructuring': [
'error',
{ VariableDeclarator: { object: true } },
],
'import/no-duplicates': 'error',
'no-negated-condition': 'off',
'unicorn/no-negated-condition': 'error',
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
'object-shorthand': ['error', 'always'],
'unicorn/prefer-regexp-test': 'error',
'unicorn/no-array-for-each': 'error',
'unicorn/prefer-string-replace-all': 'error',
'@typescript-eslint/prefer-for-of': 'error',
// todo: enable
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
},
// Rules for React files
{
files: '{packages,examples,docs}/**',
extends: [
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:@next/next/recommended',
],
rules: {
'react/prop-types': 'off',
'react/no-unknown-property': ['error', { ignore: ['jsx'] }],
'react-hooks/exhaustive-deps': 'error',
'react/self-closing-comp': 'error',
'no-restricted-syntax': [
'error',
{
// ❌ useMemo(…, [])
selector:
'CallExpression[callee.name=useMemo][arguments.1.type=ArrayExpression][arguments.1.elements.length=0]',
message:
"`useMemo` with an empty dependency array can't provide a stable reference, use `useRef` instead.",
},
{
// ❌ z.object(…)
selector:
'MemberExpression[object.name=z] > .property[name=object]',
message: 'Use z.strictObject is more safe.',
},
],
'react/jsx-filename-extension': [
'error',
{ extensions: ['.tsx', '.jsx'], allow: 'as-needed' },
],
'react/jsx-curly-brace-presence': 'error',
'react/jsx-boolean-value': 'error',
},
settings: {
react: { version: 'detect' },
},
},
// Rules for TypeScript files
{
files: '**/*.{ts,tsx,cts,mts}',
extends: [
// TODO: fix errors
// 'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
parserOptions: {
project: ['tsconfig.json'],
},
rules: {
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
},
},
],
};
213 changes: 212 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,213 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/
.pnp
.pnp.js

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
node_modules
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
.vscode/

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

## archives and compressed files
*.7z
*.jar
*.rar
*.zip
*.gz
*.bzip
*.xz
*.lzma
*.tar
*.tgz
*.tar.gz
*.iso
*.dmg
*.xpi
*.gem
*.egg
*.deb
*.rpm

## common temp file patterns
*~
*.*~
.#*
\#*#
.*.sw[a-z]

## editors and ides

### emacs
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
.elc
auto-save-list
tramp
.\#*

### vim
*.un~
Session.vim

## os-specific noise files

### linux flavors
.directory

### osx
.DS_Store
._*
.Spotlight-V100
.Trashes

### windows
Desktop.ini
$RECYCLE.BIN/
Thumbs.db

## commonly used temp files and directories
*.log
*.pid
log
logs
tmp
temp

## tags, gtags, etags, ctags
GPATH
GRTAGS
GSYMS
GTAGS
TAGS

# turbo
.turbo

# vercel
.vercel
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.next/
package.json
package-lock.json
pnpm-lock.yaml
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Nextra Docs Template
# Nextra Docs Template

This is a template for creating documentation with [Nextra](https://nextra.site).
This is a template for creating documentation with
[Nextra](https://nextra.site).

[**Live Demo →**](https://nextra-docs-template.vercel.app)

Expand Down
6 changes: 0 additions & 6 deletions components/counters.module.css

This file was deleted.

24 changes: 0 additions & 24 deletions components/counters.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const withNextra = require('nextra')({
theme: 'nextra-theme-docs',
themeConfig: './theme.config.tsx',
})
});

module.exports = withNextra()
module.exports = withNextra();
Loading

0 comments on commit 45103a2

Please sign in to comment.