Skip to content

Commit 98412cc

Browse files
Add ESLint (#167)
1 parent e5f7c7d commit 98412cc

File tree

12 files changed

+2439
-150
lines changed

12 files changed

+2439
-150
lines changed

.github/workflows/lint.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- reopened
7+
- synchronize
8+
jobs:
9+
pr-lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 1
16+
submodules: true
17+
- name: Use Node.js 20
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: 'npm'
22+
- run: npm ci
23+
- run: npm run check-format
24+
- run: npm run lint

docusaurus.config.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ const config: Config = {
269269
parseFrontMatter: async (params) => {
270270
const result = await params.defaultParseFrontMatter(params);
271271
const { frontMatter } = result;
272-
let { docPluginId, docPath } = parseDocPath(params.filePath);
272+
const parsedDocPath = parseDocPath(params.filePath);
273+
const { docPluginId } = parsedDocPath;
274+
let { docPath } = parsedDocPath;
273275
if (docPath.startsWith('external/')) {
274276
// Add a slug to all external doc pages
275277
frontMatter.slug ??= docPath
@@ -464,10 +466,6 @@ function isMarkdownUrl(href: string): boolean {
464466
return /\.mdx?(?:#|$)/.test(href);
465467
}
466468

467-
function hasProtocol(url: string): boolean {
468-
return /^(?:\w*:|\/\/)/.test(url);
469-
}
470-
471469
function externalDocUrl(docPath: string): string {
472470
const [, projectName, externalDocPath] = docPath.match(/\bexternal\/([^/]+)\/(.+)$/);
473471
return `https://github.com/THEOplayer/${projectName}/blob/-/${externalDocPath}`;

eslint.config.mjs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import globals from 'globals';
2+
import pluginJs from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
import pluginReact from 'eslint-plugin-react';
5+
import reactCompiler from 'eslint-plugin-react-compiler';
6+
import reactHooks from 'eslint-plugin-react-hooks';
7+
8+
/** @type {import('eslint').Linter.Config[]} */
9+
export default [
10+
{
11+
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
12+
languageOptions: {
13+
globals: {
14+
...globals.browser,
15+
...globals.node,
16+
},
17+
},
18+
plugins: {
19+
'react-compiler': reactCompiler,
20+
'react-hooks': reactHooks,
21+
},
22+
settings: {
23+
react: {
24+
version: 'detect',
25+
},
26+
},
27+
},
28+
pluginJs.configs.recommended,
29+
...tseslint.configs.recommended,
30+
pluginReact.configs.flat.recommended,
31+
pluginReact.configs.flat['jsx-runtime'],
32+
{
33+
rules: {
34+
'react-compiler/react-compiler': 'error',
35+
'@typescript-eslint/no-explicit-any': 'off',
36+
'@typescript-eslint/no-namespace': 'off',
37+
'@typescript-eslint/no-require-imports': 'off',
38+
'@typescript-eslint/no-unused-vars': [
39+
'error',
40+
{
41+
varsIgnorePattern: '^_|^React$',
42+
},
43+
],
44+
...reactHooks.configs.recommended.rules,
45+
},
46+
},
47+
];

0 commit comments

Comments
 (0)