File tree Expand file tree Collapse file tree 4 files changed +55
-21
lines changed Expand file tree Collapse file tree 4 files changed +55
-21
lines changed Original file line number Diff line number Diff line change 7070 ]
7171 },
7272 "lint" : {
73+ "include" : [ " ./src/components/toggle_switch/" ],
74+ "plugins" : [
75+ " ./lint/plugins/colon_spacing.ts"
76+ ],
7377 "rules" : {
7478 "tags" : [
7579 " recommended"
101105 }
102106 },
103107 "fmt" : {
104- "options" : {
105- "singleQuote" : true ,
106- "lineWidth" : 120
107- }
108+ "trailingCommas" : " never" ,
109+ "singleQuote" : true ,
110+ "lineWidth" : 120
108111 },
109112 "imports" : {
110113 "@deno/esbuild-plugin" : " jsr:@deno/esbuild-plugin@^1.2.0" ,
Original file line number Diff line number Diff line change 1+ /// <reference lib="deno.ns" />
2+ /// <reference lib="deno.unstable" />
3+
4+ export default {
5+ name : "colon-spacing" ,
6+ rules : {
7+ "after-function" : {
8+ create ( context ) : Deno . lint . LintVisitor {
9+ return {
10+ TSTypeAnnotation ( node ) : void {
11+ if ( node . parent . type === 'FunctionDeclaration' ) {
12+ const functionStart = node . parent . range [ 0 ] ;
13+ const sectionEnd = node . range [ 0 ]
14+ const index = context . sourceCode . getText ( node . parent ) . substring ( 0 , sectionEnd - functionStart ) . search ( / \) * $ / ) + 1
15+ const sectionStart = functionStart + index ;
16+
17+ if ( index !== - 1 && sectionEnd - sectionStart !== 1 ) {
18+ context . report ( {
19+ message : `Wrong colon spacing. [${ sectionStart } , ${ sectionEnd } ]` ,
20+ range : [ sectionStart - 1 , sectionEnd + 1 ] ,
21+ fix ( fixer ) {
22+ return fixer . replaceTextRange ( [ sectionStart , sectionEnd ] , ' ' )
23+ } ,
24+ } )
25+ }
26+ }
27+ }
28+ }
29+ }
30+ }
31+ }
32+ } satisfies Deno . lint . Plugin
Original file line number Diff line number Diff line change 1- import { mergeProps , type JSXElement } from '@solid-js'
2- import { buttonTypes , type ButtonType } from './button_types.ts' ;
3- import './index.css'
4-
1+ import { type JSXElement , mergeProps } from '@solid-js' ;
2+ import { type ButtonType , buttonTypes } from './button_types.ts' ;
3+ import './index.css' ;
54
65export function Button ( props : {
7- type ?: ButtonType ,
8- children : JSXElement
9- } ) : JSXElement {
6+ type ?: ButtonType ;
7+ children : JSXElement ;
8+ } ) : JSXElement {
109 const properties = mergeProps ( { type : buttonTypes . DEFAULT } , props ) ;
1110
1211 return (
1312 < button
1413 type = 'button'
1514 class = { `ui button button--${ properties . type } ` }
1615 data-type = { properties . type }
17- > { properties . children } </ button >
18- )
16+ >
17+ { properties . children }
18+ </ button >
19+ ) ;
1920}
Original file line number Diff line number Diff line change 1- import { type JSXElement , createSignal } from '@solid-js'
1+ import { createSignal , type JSXElement } from '@solid-js' ;
22
3- import './index.css'
4-
5-
6- export function ToggleSwitch ( ) : JSXElement {
3+ import './index.css' ;
74
5+ export default function ToggleSwitch ( _foo : string , _bar : string ) : JSXElement {
86 const [ state , setState ] = createSignal ( false ) ;
97
108 const toggle = ( ) => {
119 setState ( ( v ) => ! v ) ;
1210 console . log ( 'State is now:' , state ( ) ) ;
13- }
11+ } ;
1412
1513 return (
1614 < button
1715 type = 'button'
18- class = { ` ui toggle-switch` }
16+ class = ' ui toggle-switch'
1917 classList = { {
2018 'toggle-switch--active' : state ( )
2119 } }
@@ -24,5 +22,5 @@ export function ToggleSwitch() : JSXElement {
2422 >
2523 { state ( ) ? 'ON' : 'OFF' }
2624 </ button >
27- )
25+ ) ;
2826}
You can’t perform that action at this time.
0 commit comments