Skip to content

Commit 1ea91b8

Browse files
TinooooTino Koch
and
Tino Koch
authored
feat: 50 similar linting rules throughout the tresjs packages (#51)
* feature: added eslint rules to have homogeneous rules in the tres ecosystem * chore: applied eslint fixes * chore: moved linting rules to correct position --------- Co-authored-by: Tino Koch <[email protected]>
1 parent ab56b2d commit 1ea91b8

23 files changed

+1303
-130
lines changed

.eslintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
dist
2+
**.spec.js
3+
**.test.ts
4+
**.test.js
5+
**.cy.js
6+
**/cypress/**
7+
docs/.vitepress/cache
8+
docs/.vitepress/dist

.eslintrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@tresjs/eslint-config-vue",
3+
"rules": {
4+
"@typescript-eslint/no-use-before-define": "off",
5+
"vue/valid-template-root": "off"
6+
}
7+
}

.prettierrc.cjs

-4
This file was deleted.

docs/.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@tresjs/eslint-config-vue"
3+
}

docs/.vitepress/theme/TresLayout.vue

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup>
2+
// eslint-disable-next-line import/no-named-as-default
23
import DefaultTheme from 'vitepress/theme'
34
import LoveVueThreeJS from './components/LoveVueThreeJS.vue'
45

docs/.vitepress/theme/components/BloomDemo.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ const bloomParams = reactive({
2424

2525
<template>
2626
<TresCanvas v-bind="gl">
27-
<TresPerspectiveCamera :position="[5, 5, 5]" :look-at="[0, 0, 0]" />
27+
<TresPerspectiveCamera
28+
:position="[5, 5, 5]"
29+
:look-at="[0, 0, 0]"
30+
/>
2831
<TresMesh>
2932
<TresSphereGeometry :args="[2, 32, 32]" />
3033
<TresMeshStandardMaterial
31-
ref="materialRef"
3234
color="hotpink"
3335
:emissive="new Color('hotpink')"
3436
:emissive-intensity="1.2"
@@ -37,10 +39,13 @@ const bloomParams = reactive({
3739
<TresGridHelper />
3840

3941
<TresAmbientLight :intensity="2" />
40-
<TresDirectionalLight :position="[3, 3, 3]" :intensity="1" />
42+
<TresDirectionalLight
43+
:position="[3, 3, 3]"
44+
:intensity="1"
45+
/>
4146
<Suspense>
4247
<EffectComposer>
43-
<Bloom v-bind="bloomParams"> </Bloom>
48+
<Bloom v-bind="bloomParams" />
4449
</EffectComposer>
4550
</Suspense>
4651
</TresCanvas>

docs/.vitepress/theme/components/GlitchDemo.vue

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ const gl = {
1515

1616
<template>
1717
<TresCanvas v-bind="gl">
18-
<TresPerspectiveCamera :position="[0, 1, 5]" :look-at="[0, 0, 0]" />
18+
<TresPerspectiveCamera
19+
:position="[0, 1, 5]"
20+
:look-at="[0, 0, 0]"
21+
/>
1922
<Suspense>
2023
<Text3D
2124
:position="[0, 1, 0]"
2225
text="Post-processing"
2326
font="https://raw.githubusercontent.com/Tresjs/assets/main/fonts/FiraCodeRegular.json"
2427
>
2528
<TresMeshStandardMaterial
26-
ref="materialRef"
2729
color="hotpink"
2830
:emissive="new Color('hotpink')"
2931
:emissive-intensity="1.2"
@@ -33,7 +35,10 @@ const gl = {
3335
<TresGridHelper />
3436

3537
<TresAmbientLight :intensity="2" />
36-
<TresDirectionalLight :position="[3, 3, 3]" :intensity="1" />
38+
<TresDirectionalLight
39+
:position="[3, 3, 3]"
40+
:intensity="1"
41+
/>
3742
<Suspense>
3843
<EffectComposer>
3944
<Glitch />

docs/.vitepress/theme/components/LoveVueThreeJS.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script setup lang="ts">
22
///<reference types="vite-svg-loader" />
3+
// eslint-disable-next-line import/no-named-as-default
4+
import gsap from 'gsap'
5+
import { onMounted, ref } from 'vue'
36
import Triangle from '../assets/triangle.svg'
47
import SecondRow from '../assets/second-row.svg'
58
import ThirdRow from '../assets/third-row.svg'
6-
import gsap from 'gsap'
7-
import { onMounted, ref } from 'vue'
89
910
const triangleRef = ref()
1011
const secondRowRef = ref()
@@ -19,13 +20,13 @@ async function restartAnimation() {
1920
gsap.to(secondRowRef.value.$el, {
2021
duration: 1,
2122
y: 0,
22-
ease: "elastic.out(0.7, 0.2)",
23+
ease: 'elastic.out(0.7, 0.2)',
2324
})
2425
await gsap.to(thirdRowRef.value.$el, {
2526
delay: 0.65,
2627
duration: 1,
2728
y: 0,
28-
ease: "steps(4)",
29+
ease: 'steps(4)',
2930
})
3031
3132
tl2r.restart()
@@ -43,13 +44,16 @@ onMounted(() => {
4344
delay: 1.25,
4445
duration: 2,
4546
y: -(12 * heightOfSignleSvg),
46-
ease: "power1.out",
47+
ease: 'power1.out',
4748
})
4849
})
4950
</script>
5051

5152
<template>
52-
<div class="grid items-center w-full min-w-370px -translate-x-20px md:translate-x-20px h-full scale-75" @click="restartAnimation">
53+
<div
54+
class="grid items-center w-full min-w-370px -translate-x-20px md:translate-x-20px h-full scale-75"
55+
@click="restartAnimation"
56+
>
5357
<div class="grid grid-cols-3 gap-8 overflow-hidden h-93px">
5458
<Triangle ref="triangleRef" />
5559
<SecondRow ref="secondRowRef" />

docs/.vitepress/theme/components/OutlineDemo.vue

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<script lang="ts" setup>
2-
import { ref } from 'vue'
2+
import { ref, shallowRef } from 'vue'
33
import { watchOnce } from '@vueuse/core'
4-
import { shallowRef } from 'vue'
54
import { TresCanvas } from '@tresjs/core'
65
import { KernelSize } from 'postprocessing'
76
import { EffectComposer, Outline } from '/@'
8-
import { Color, Intersection, Object3D } from 'three'
7+
import type { Intersection, Object3D } from 'three'
8+
import { Color } from 'three'
99
1010
const boxWidth = 2
1111
const outlinedObjects = ref<Object3D[]>([])
@@ -25,21 +25,36 @@ watchOnce(meshes, () => {
2525
</script>
2626

2727
<template>
28-
<TresCanvas clear-color="#121212" :alpha="false" :shadows="true" :disable-render="true">
29-
<TresPerspectiveCamera :position="[3, 3, 4]" :look-at="[0, 0, 0]" />
28+
<TresCanvas
29+
clear-color="#121212"
30+
:alpha="false"
31+
:shadows="true"
32+
:disable-render="true"
33+
>
34+
<TresPerspectiveCamera
35+
:position="[3, 3, 4]"
36+
:look-at="[0, 0, 0]"
37+
/>
3038
<TresMesh
31-
ref="meshes"
3239
v-for="i in 3"
40+
ref="meshes"
3341
:key="i.toString()"
3442
:position="[(i - 2) * boxWidth, 0.5, 1]"
3543
@click="toggleMeshSelectionState"
3644
>
3745
<TresBoxGeometry />
38-
<TresMeshStandardMaterial color="hotpink" :emissive="new Color('hotpink')" :emissive-intensity="1" />
46+
<TresMeshStandardMaterial
47+
color="hotpink"
48+
:emissive="new Color('hotpink')"
49+
:emissive-intensity="1"
50+
/>
3951
</TresMesh>
4052
<TresGridHelper />
4153
<TresAmbientLight :intensity="2" />
42-
<TresDirectionalLight :position="[-4, 4, 3]" :intensity="2" />
54+
<TresDirectionalLight
55+
:position="[-4, 4, 3]"
56+
:intensity="2"
57+
/>
4358

4459
<Suspense>
4560
<EffectComposer>

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"preview": "vite preview",
3838
"release": "release-it",
3939
"lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
40+
"lint:fix": "pnpm run lint --fix",
4041
"docs:dev": "vitepress dev docs",
4142
"docs:build": "vitepress build docs",
4243
"docs:preview": "vitepress preview docs"
@@ -52,8 +53,8 @@
5253
"three-stdlib": "^2.23.10"
5354
},
5455
"devDependencies": {
55-
"@alvarosabu/prettier-config": "^1.3.0",
5656
"@release-it/conventional-changelog": "^5.1.1",
57+
"@tresjs/eslint-config-vue": "^0.1.1",
5758
"@types/three": "^0.152.1",
5859
"@vitejs/plugin-vue": "^4.2.3",
5960
"gsap": "^3.12.1",

playground/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "@tresjs/eslint-config-vue",
3+
"rules": {
4+
"no-console": "off"
5+
}
6+
}

playground/src/components/GlitchDemo.vue

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import { TresCanvas } from '@tresjs/core'
33
import { OrbitControls, useTweakPane } from '@tresjs/cientos'
44
import { EffectComposer, Glitch } from '@tresjs/post-processing'
5-
import { BasicShadowMap, NoToneMapping, SRGBColorSpace } from 'three'
5+
import { BasicShadowMap, NoToneMapping, SRGBColorSpace, Vector2 } from 'three'
66
import { reactive } from 'vue'
77
import { GlitchMode } from 'postprocessing'
8-
import { Vector2 } from 'three'
98
109
const gl = {
1110
clearColor: '#121212',
@@ -48,8 +47,14 @@ pane.addInput(glitchParams, 'dtSize', { min: 1, max: 64, step: 1 })
4847
</script>
4948

5049
<template>
51-
<TresCanvas v-bind="gl" :disable-render="true">
52-
<TresPerspectiveCamera :position="[5, 5, 5]" :look-at="[0, 0, 0]" />
50+
<TresCanvas
51+
v-bind="gl"
52+
:disable-render="true"
53+
>
54+
<TresPerspectiveCamera
55+
:position="[5, 5, 5]"
56+
:look-at="[0, 0, 0]"
57+
/>
5358
<OrbitControls />
5459
<TresMesh>
5560
<TresSphereGeometry :args="[2, 32, 32]" />

playground/src/components/OutlineDemo.vue

+23-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { TresCanvas } from '@tresjs/core'
33
import { OrbitControls, useTweakPane } from '@tresjs/cientos'
44
import { reactive, ref } from 'vue'
55
import { EffectComposer, Outline } from '@tresjs/post-processing'
6-
import { BasicShadowMap, NoToneMapping, Object3D, Intersection } from 'three'
6+
import type { Object3D, Intersection } from 'three'
7+
import { BasicShadowMap, NoToneMapping } from 'three'
78
89
const gl = {
910
alpha: false,
@@ -37,11 +38,24 @@ pane.addInput(outlineParameters, 'visibleEdgeColor')
3738

3839
<template>
3940
<TresCanvas v-bind="gl">
40-
<TresPerspectiveCamera :position="[3, 3, 3]" :look-at="[2, 2, 2]" />
41+
<TresPerspectiveCamera
42+
:position="[3, 3, 3]"
43+
:look-at="[2, 2, 2]"
44+
/>
4145
<OrbitControls />
42-
<template v-for="i in 5" :key="i">
43-
<TresMesh @click="toggleMeshSelectionState" :position="[i * 1.1 - 2.8, 1, 0]">
44-
<TresBoxGeometry :width="4" :height="4" :depth="4" />
46+
<template
47+
v-for="i in 5"
48+
:key="i"
49+
>
50+
<TresMesh
51+
:position="[i * 1.1 - 2.8, 1, 0]"
52+
@click="toggleMeshSelectionState"
53+
>
54+
<TresBoxGeometry
55+
:width="4"
56+
:height="4"
57+
:depth="4"
58+
/>
4559
<TresMeshNormalMaterial />
4660
</TresMesh>
4761
</template>
@@ -50,7 +64,10 @@ pane.addInput(outlineParameters, 'visibleEdgeColor')
5064
<TresAmbientLight :intensity="1" />
5165
<Suspense>
5266
<EffectComposer>
53-
<Outline :outlined-objects="outlinedObjects" v-bind="outlineParameters" />
67+
<Outline
68+
:outlined-objects="outlinedObjects"
69+
v-bind="outlineParameters"
70+
/>
5471
</EffectComposer>
5572
</Suspense>
5673
</TresCanvas>

playground/src/components/TheExperience.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ const gl = {
1414
</script>
1515

1616
<template>
17-
<TresCanvas v-bind="gl" disable-render>
18-
<TresPerspectiveCamera :position="[5, 5, 5]" :look-at="[0, 0, 0]" />
17+
<TresCanvas
18+
v-bind="gl"
19+
disable-render
20+
>
21+
<TresPerspectiveCamera
22+
:position="[5, 5, 5]"
23+
:look-at="[0, 0, 0]"
24+
/>
1925

2026
<TresMesh>
2127
<TresSphereGeometry :args="[2, 32, 32]" />

playground/src/components/UnrealBloom.vue

+19-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<script setup lang="ts">
2-
import { Color } from 'three'
2+
import { Color, BasicShadowMap, NoToneMapping } from 'three'
33
import { TresCanvas } from '@tresjs/core'
44
import { OrbitControls, useTweakPane } from '@tresjs/cientos'
55
import { BlendFunction } from 'postprocessing'
66
import { EffectComposer, Bloom } from '@tresjs/post-processing'
77
import { onMounted, reactive, ref } from 'vue'
8-
import { BasicShadowMap, NoToneMapping } from 'three'
98
109
const gl = {
1110
clearColor: '#121212',
@@ -40,12 +39,22 @@ onMounted(() => {
4039
</script>
4140

4241
<template>
43-
<TresCanvas v-bind="gl" :disable-render="true">
44-
<TresPerspectiveCamera :position="[5, 5, 5]" :look-at="[0, 0, 0]" />
42+
<TresCanvas
43+
v-bind="gl"
44+
:disable-render="true"
45+
>
46+
<TresPerspectiveCamera
47+
:position="[5, 5, 5]"
48+
:look-at="[0, 0, 0]"
49+
/>
4550
<OrbitControls />
4651
<TresMesh>
4752
<TresSphereGeometry :args="[2, 32, 32]" />
48-
<TresMeshStandardMaterial color="hotpink" :emissive="new Color('hotpink')" :emissive-intensity="9" />
53+
<TresMeshStandardMaterial
54+
color="hotpink"
55+
:emissive="new Color('hotpink')"
56+
:emissive-intensity="9"
57+
/>
4958
</TresMesh>
5059
<TresMesh :position="[2, 2, -2]">
5160
<TresSphereGeometry :args="[2, 32, 32]" />
@@ -62,10 +71,13 @@ onMounted(() => {
6271
</TresMesh>
6372
<TresGridHelper />
6473
<TresAmbientLight :intensity="0.5" />
65-
<TresDirectionalLight :position="[3, 3, 3]" :intensity="2" />
74+
<TresDirectionalLight
75+
:position="[3, 3, 3]"
76+
:intensity="2"
77+
/>
6678
<Suspense>
6779
<EffectComposer :depth-buffer="true">
68-
<Bloom v-bind="bloomParams"></Bloom>
80+
<Bloom v-bind="bloomParams" />
6981
</EffectComposer>
7082
</Suspense>
7183
</TresCanvas>

playground/src/pages/glitch.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
<script lang="ts" setup></script>
2+
13
<template>
24
<GlitchDemo />
35
</template>
4-
5-
<script lang="ts" setup></script>

0 commit comments

Comments
 (0)