Skip to content

Commit

Permalink
Configure eslint & prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
fuma-nama committed Jul 30, 2023
1 parent a4ef604 commit d847dca
Show file tree
Hide file tree
Showing 140 changed files with 7,631 additions and 5,119 deletions.
18 changes: 9 additions & 9 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [["next-docs-zeta", "next-docs-ui"]],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["website", "docs"]
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [["next-docs-zeta", "next-docs-ui"]],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["website", "docs"]
}
121 changes: 121 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
const TAILWIND_CONFIG = {
extends: ['plugin:tailwindcss/recommended'],
rules: {
// by prettier-plugin-tailwindcss
'tailwindcss/classnames-order': 'off',
'tailwindcss/enforces-negative-arbitrary-values': 'error',
'tailwindcss/enforces-shorthand': 'error',
'tailwindcss/migration-from-tailwind-2': 'error',
'tailwindcss/no-custom-classname': 'error'
}
}

/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
reportUnusedDisableDirectives: true,
ignorePatterns: ['next-env.d.ts'],
overrides: [
// Rules for all files
{
files: '**/*.{js,jsx,cjs,mjs,ts,tsx,cts,mts}',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'prefer-object-has-own': 'error',
'logical-assignment-operators': [
'error',
'always',
{ enforceForIfStatements: true }
],
'no-negated-condition': 'off',
'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
'object-shorthand': ['error', 'always'],

'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-imports': 'error'
}
},
// React.js rules
{
files: '{packages,examples,apps}/**',
extends: [
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:@next/next/recommended'
],
rules: {
// it breaks the use of component libraries
'react/prop-types': 'off',
'react/no-unknown-property': 'off',
'react/jsx-curly-brace-presence': 'error',
'react/jsx-boolean-value': 'error'
},
settings: {
react: { version: 'detect' }
}
},
{
...TAILWIND_CONFIG,
files: 'packages/next-docs-ui/**',
settings: {
tailwindcss: {
config: 'packages/next-docs-ui/tailwind.config.js',
callees: ['cn', 'clsx']
}
}
},
{
...TAILWIND_CONFIG,
files: 'apps/docs/**',
settings: {
tailwindcss: {
config: 'apps/docs/tailwind.config.js',
callees: ['cn', 'clsx', 'cva'],
whitelist: ['nd-not-prose']
},
next: { rootDir: 'apps/docs' }
}
},
{
...TAILWIND_CONFIG,
files: 'examples/website/**',
settings: {
tailwindcss: {
config: 'examples/website/tailwind.config.js'
},
next: { rootDir: 'examples/website' }
}
},
{
files: [
'prettier.config.js',
'postcss.config.js',
'tailwind.config.js',
'next.config.js',
'.eslintrc.cjs'
],
env: {
node: true
},
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
{
files: 'packages/{next-docs-ui,next-docs}/**',
rules: {
'@next/next/no-html-link-for-pages': 'off'
}
},
{
files: ['**/*.d.ts'],
rules: {
'no-var': 'off'
}
}
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ node_modules
out
dist
.contentlayer
.eslintcache

# production
/build
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm-lock.yaml
.changeset/*.md
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
"typescript.tsdk": "node_modules\\typescript\\lib"
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ npm install next-docs-zeta

### Next Docs UI

The framework built on top of Next Docs Zeta. It offers many out-of-the-box features along with a well-designed user interface.
The framework built on top of Next Docs Zeta. It offers many out-of-the-box
features along with a well-designed user interface.

```bash
npm install next-docs-ui
Expand All @@ -30,7 +31,8 @@ npm install next-docs-ui

[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?style=flat-square&logo=codesandbox)](https://githubbox.com/SonMooSans/next-docs-ui-template)

View the [Template](https://github.com/SonMooSans/next-docs-ui-template) repository on Github.
View the [Template](https://github.com/SonMooSans/next-docs-ui-template)
repository on Github.

### Sources

Expand Down
16 changes: 8 additions & 8 deletions apps/docs/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { allDocs } from "contentlayer/generated";
import { initSearchAPI } from "next-docs-zeta/server";
import { allDocs } from 'contentlayer/generated'
import { initSearchAPI } from 'next-docs-zeta/server'

export const { GET } = initSearchAPI(
allDocs.map((docs) => ({
title: docs.title,
content: docs.body.raw,
url: "/docs/" + docs.slug,
}))
);
allDocs.map(docs => ({
title: docs.title,
content: docs.body.raw,
url: '/docs/' + docs.slug
}))
)
2 changes: 1 addition & 1 deletion apps/docs/app/docs/[mode]/[[...slug]]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default } from "next-docs-ui/not-found";
export { default } from 'next-docs-ui/not-found'
Loading

0 comments on commit d847dca

Please sign in to comment.