style: apply eslint rules to top level and website js files

pull/608/head
hasezoey 2 years ago
parent 38880dd959
commit 7404c44c84
No known key found for this signature in database
GPG Key ID: 9F8C99E834CC54FB
  1. 5
      .eslintignore
  2. 52
      .eslintrc.js
  3. 16
      commitlint.config.js
  4. 2
      lint-staged.config.js
  5. 3
      tsconfig.build.json
  6. 8
      tsconfig.json
  7. 2
      website/docusaurus.config.js
  8. 55
      website/sidebars.js
  9. 33
      website/src/pages/index.js

@ -1,6 +1,7 @@
flow-typed/*
lib/*
build/*
website/*
#website/* #dont ignore website (like sidebars.js)
website/build/*
coverage/*
*.js
#*.js # dont ignore top-level js files

@ -1,18 +1,14 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
extends: ['plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
parserOptions: {
sourceType: 'module',
useJSXTextNode: true,
project: [
path.resolve(__dirname, 'tsconfig.json'),
],
project: [path.resolve(__dirname, 'tsconfig.json')],
},
rules: {
'no-underscore-dangle': 0,
@ -43,37 +39,55 @@ module.exports = {
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'curly': ['error', 'all'],
curly: ['error', 'all'],
'padding-line-between-statements': [
"warn",
'warn',
{
blankLine: 'always', prev: '*', next: 'return' // add blank line *before* all returns (if there are statements before)
blankLine: 'always',
prev: '*',
next: 'return', // add blank line *before* all returns (if there are statements before)
},
{
blankLine: 'always', prev: '*', next: 'if' // add blank line *before* all ifs
blankLine: 'always',
prev: '*',
next: 'if', // add blank line *before* all ifs
},
{
blankLine: 'always', prev: 'if', next: '*' // add blank line *after* all ifs
blankLine: 'always',
prev: 'if',
next: '*', // add blank line *after* all ifs
},
{
blankLine: 'any', prev: 'if', next: 'if' // allow blank line between ifs, but not enforce either
blankLine: 'any',
prev: 'if',
next: 'if', // allow blank line between ifs, but not enforce either
},
{
blankLine: 'always', prev: '*', next: ['function', 'class'] // add blank line *before* all functions and classes
blankLine: 'always',
prev: '*',
next: ['function', 'class'], // add blank line *before* all functions and classes
},
{
blankLine: 'always', prev: ['function', 'class'], next: '*' // add blank line *after* all functions and classes
blankLine: 'always',
prev: ['function', 'class'],
next: '*', // add blank line *after* all functions and classes
},
{
blankLine: 'always', prev: '*', next: 'import' // add blank line *before* all imports
blankLine: 'always',
prev: '*',
next: 'import', // add blank line *before* all imports
},
{
blankLine: 'always', prev: 'import', next: '*' // add blank line *after* all imports
blankLine: 'always',
prev: 'import',
next: '*', // add blank line *after* all imports
},
{
blankLine: 'never', prev: 'import', next: 'import' // dont allow blank line between imports
blankLine: 'never',
prev: 'import',
next: 'import', // dont allow blank line between imports
},
]
],
},
env: {
node: true,

@ -1,11 +1,9 @@
module.exports = {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"scope-case": [0, "never"],
"body-min-length": [2, "always", 3],
"footer-max-line-length": [1, "always", 200],
"type-enum": [2, "always", ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'revert', 'dependencies', 'release']]
}
extends: ['@commitlint/config-conventional'],
rules: {
'scope-case': [0, 'never'],
'body-min-length': [2, 'always', 3],
'footer-max-line-length': [1, 'always', 200],
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'revert', 'dependencies', 'release']],
},
};

@ -1,3 +1,3 @@
module.exports = {
"**/*.{ts,js}": "yarn run lint --fix"
'**/*.{ts,js}': 'yarn run lint --fix',
};

@ -1,7 +1,8 @@
{
"extends": "./tsconfig.json",
"exclude": [
"test/**/*.ts"
"test/**/*.ts",
"*.js"
],
"compilerOptions": {
"outDir": "lib"

@ -21,9 +21,13 @@
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
"test/**/*.ts",
"*.js",
".*.js",
"website/**/*.js"
],
"exclude": [
"node_modules/**/*"
"**/*/node_modules/**/*",
"website/build/**/*"
]
}

@ -56,7 +56,7 @@ module.exports = {
{
label: 'Discord',
href: 'https://discord.gg/BpGjTTD',
}
},
],
},
{

@ -1,15 +1,50 @@
module.exports = {
docs: {
Start: ["api/index-api", "api/virtuals", "api/environment-variables"],
Decorators: ["api/decorators/prop", "api/decorators/model-options", "api/decorators/hooks", "api/decorators/indexes", "api/decorators/plugins", "api/decorators/query-method"],
Functions: ["api/functions/get-model-for-class", "api/functions/get-class-for-document", "api/functions/get-class", "api/functions/build-schema", "api/functions/get-discriminator-model-for-class", "api/functions/add-model-to-typegoose", "api/functions/delete-model", "api/functions/set-global-options", "api/functions/get-model-with-string", "api/functions/get-name"],
TypeGuards: ["api/functions/typeguards/is-document", "api/functions/typeguards/is-ref-type"],
Types: ["api/types/document-type", "api/types/return-model-type", "api/types/ref-type", "api/types/additional-types"]
Start: ['api/index-api', 'api/virtuals', 'api/environment-variables'],
Decorators: [
'api/decorators/prop',
'api/decorators/model-options',
'api/decorators/hooks',
'api/decorators/indexes',
'api/decorators/plugins',
'api/decorators/query-method',
],
Functions: [
'api/functions/get-model-for-class',
'api/functions/get-class-for-document',
'api/functions/get-class',
'api/functions/build-schema',
'api/functions/get-discriminator-model-for-class',
'api/functions/add-model-to-typegoose',
'api/functions/delete-model',
'api/functions/set-global-options',
'api/functions/get-model-with-string',
'api/functions/get-name',
],
TypeGuards: ['api/functions/typeguards/is-document', 'api/functions/typeguards/is-ref-type'],
Types: ['api/types/document-type', 'api/types/return-model-type', 'api/types/ref-type', 'api/types/additional-types'],
},
guides: {
"Getting Started": ["guides/quick-start-guide", "guides/faq", "guides/known-issues", "guides/deprecation-codes", "guides/error-warning-details"],
Basics: ["guides/all-decorators", "guides/motivation", "guides/default-classes", "guides/use-without-emitDecoratorMetadata"],
Advanced: ["guides/advanced/custom-types", "guides/advanced/array-types", "guides/advanced/models-with-same-name", "guides/advanced/logger", "guides/advanced/reference-other-classes", "guides/advanced/common-plugins", "guides/advanced/change-id-type", "guides/advanced/using-objectid-type", "guides/advanced/using-with-class-transformer", "guides/advanced/non-nested-discriminators"],
Migration: ["guides/mongoose-compatibility", "guides/migrate-8", "guides/migrate-7", "guides/migrate-6"]
}
'Getting Started': [
'guides/quick-start-guide',
'guides/faq',
'guides/known-issues',
'guides/deprecation-codes',
'guides/error-warning-details',
],
Basics: ['guides/all-decorators', 'guides/motivation', 'guides/default-classes', 'guides/use-without-emitDecoratorMetadata'],
Advanced: [
'guides/advanced/custom-types',
'guides/advanced/array-types',
'guides/advanced/models-with-same-name',
'guides/advanced/logger',
'guides/advanced/reference-other-classes',
'guides/advanced/common-plugins',
'guides/advanced/change-id-type',
'guides/advanced/using-objectid-type',
'guides/advanced/using-with-class-transformer',
'guides/advanced/non-nested-discriminators',
],
Migration: ['guides/mongoose-compatibility', 'guides/migrate-8', 'guides/migrate-7', 'guides/migrate-6'],
},
};

@ -9,34 +9,22 @@ import styles from './styles.module.css';
const features = [
{
title: <>Easy to Use</>,
description: (
<>
Typegoose was designed to easily use mongoose schema's & model's in typescript
</>
),
description: <>Typegoose was designed to easily use mongoose schema's & model's in typescript</>,
},
{
title: <>Focus on What Matters</>,
description: (
<>
Typegoose lets you focus on your data, and typegoose will create the correct
mappings to schema's and model's
</>
),
description: <>Typegoose lets you focus on your data, and typegoose will create the correct mappings to schema's and model's</>,
},
{
// didnt know what to write here
title: <>Works</>,
description: (
<>
Typegoose is compatible with almost every mongoose option
</>
),
description: <>Typegoose is compatible with almost every mongoose option</>,
},
];
function Feature({ imageUrl, title, description }) {
const imgUrl = useBaseUrl(imageUrl);
return (
<div className={clsx('col col--4', styles.feature)}>
{imgUrl && (
@ -53,21 +41,18 @@ function Feature({ imageUrl, title, description }) {
function Home() {
const context = useDocusaurusContext();
const { siteConfig = {} } = context;
return (
<Layout
title={`Welcome to ${siteConfig.title}`}
description="Description will go into a meta tag in <head />">
<Layout title={`Welcome to ${siteConfig.title}`} description="Description will go into a meta tag in <head />">
<header className={clsx('hero hero--primary', styles.heroBanner)}>
<div className="container">
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link
className={clsx(
'button button--outline button--secondary button--lg',
styles.getStarted,
)}
to={useBaseUrl('docs/guides/quick-start-guide')}>
className={clsx('button button--outline button--secondary button--lg', styles.getStarted)}
to={useBaseUrl('docs/guides/quick-start-guide')}
>
Get Started
</Link>
</div>

Loading…
Cancel
Save