forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: add import and stricter lint (element-plus#3440)
* style: add import lint * chore: apply eslint rules * chore: add stricter lint * chore: lint all files * auto fix * manually fix * restore build-indices.ts
- Loading branch information
Showing
147 changed files
with
669 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
node_modules | ||
dist | ||
packages/*/es | ||
packages/*/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,65 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
'use strict' | ||
// TODO: implement this feature | ||
|
||
import fs from 'fs' | ||
import algoliasearch from 'algoliasearch' | ||
import fg from 'fast-glob' | ||
// import fs from 'fs' | ||
// import algoliasearch from 'algoliasearch' | ||
// import fg from 'fast-glob' | ||
|
||
interface Index { | ||
component: string | ||
title: string | ||
anchor: string | ||
content: string | ||
sort: number | ||
path: string | ||
} | ||
// interface Index { | ||
// component: string | ||
// title: string | ||
// anchor: string | ||
// content: string | ||
// sort: number | ||
// path: string | ||
// } | ||
|
||
const algoliaKey = process.env.ALGOLIA_KEY! | ||
// const algoliaKey = process.env.ALGOLIA_KEY! | ||
|
||
const client = algoliasearch('7DCTSU0WBW', algoliaKey) | ||
const langs = { | ||
'zh-CN': 'element-zh', | ||
'en-US': 'element-en', | ||
es: 'element-es', | ||
'fr-FR': 'element-fr', | ||
jp: 'element-jp', | ||
} | ||
;['zh-CN', 'en-US', 'es', 'fr-FR', 'jp'].forEach((lang) => { | ||
const indexName = langs[lang] | ||
const index = client.initIndex(indexName) | ||
index | ||
.clearObjects() | ||
.then(() => { | ||
const files = fg.sync(`website/docs/${lang}/*.md`) | ||
let indices: Index[] = [] | ||
files.forEach((file) => { | ||
const regExp = new RegExp(`website\/docs\/${lang}\/(.*).md`) | ||
const pathContent = file.match(regExp)! | ||
const path = pathContent[1] | ||
const index = path.lastIndexOf('/') | ||
const names = index !== -1 ? path.split('/') : [] | ||
const component = names.length ? names[names.length - 1] : path | ||
const content = fs.readFileSync(file, 'utf8') | ||
const matches = content | ||
.replace(/:::[\s\S]*?:::/g, '') | ||
.replace(/```[\s\S]*?```/g, '') | ||
.match(/#{2,4}[^#]*/g)! | ||
.map((match) => | ||
match | ||
.replace(/\n+/g, '\n') | ||
.split('\n') | ||
.filter((part) => !!part) | ||
) | ||
}) | ||
// const client = algoliasearch('7DCTSU0WBW', algoliaKey) | ||
// const langs = { | ||
// 'zh-CN': 'element-zh', | ||
// 'en-US': 'element-en', | ||
// es: 'element-es', | ||
// 'fr-FR': 'element-fr', | ||
// jp: 'element-jp', | ||
// } | ||
// ;['zh-CN', 'en-US', 'es', 'fr-FR', 'jp'].forEach((lang) => { | ||
// const indexName = langs[lang] | ||
// const index = client.initIndex(indexName) | ||
// index | ||
// .clearObjects() | ||
// .then(() => { | ||
// const files = fg.sync(`website/docs/${lang}/*.md`) | ||
// let indices: Index[] = [] | ||
// files.forEach((file) => { | ||
// const regExp = new RegExp(`website\/docs\/${lang}\/(.*).md`) | ||
// const pathContent = file.match(regExp)! | ||
// const path = pathContent[1] | ||
// const index = path.lastIndexOf('/') | ||
// const names = index !== -1 ? path.split('/') : [] | ||
// const component = names.length ? names[names.length - 1] : path | ||
// const content = fs.readFileSync(file, 'utf8') | ||
// const matches = content | ||
// .replace(/:::[\s\S]*?:::/g, '') | ||
// .replace(/```[\s\S]*?```/g, '') | ||
// .match(/#{2,4}[^#]*/g)! | ||
// .map((match) => | ||
// match | ||
// .replace(/\n+/g, '\n') | ||
// .split('\n') | ||
// .filter((part) => !!part) | ||
// ) | ||
// }) | ||
|
||
index | ||
.saveObjects(indices, { | ||
autoGenerateObjectIDIfNotExist: true, | ||
}) | ||
.catch((e) => { | ||
console.log(e) | ||
}) | ||
}) | ||
.catch((e) => { | ||
console.log(e) | ||
}) | ||
}) | ||
// index | ||
// .saveObjects(indices, { | ||
// autoGenerateObjectIDIfNotExist: true, | ||
// }) | ||
// .catch((e) => { | ||
// console.log(e) | ||
// }) | ||
// }) | ||
// .catch((e) => { | ||
// console.log(e) | ||
// }) | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.