-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix(Language Service): Class is incorrectly positioned in literals
- Loading branch information
Showing
7 changed files
with
66 additions
and
9 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,6 +1,9 @@ | ||
import React from 'react' | ||
import styled from '@master/styled.react' | ||
import clsx from 'clsx' | ||
|
||
export default () => <div className="">hello world</div> | ||
export const A = () => <div className={`block ${'content:\'123\''}`}>hello world</div> | ||
export const B = () => <div className={clsx('class-a class-b', `class-c class-d | ||
class-d`)}></div> | ||
|
||
const Button = styled.button('text:center') |
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
22 changes: 22 additions & 0 deletions
22
packages/language-service/tests/get-class-position/styled.test.ts
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import dedent from 'ts-dedent' | ||
import { expectClassPosition } from './test' | ||
|
||
test('styled template literal', () => { | ||
const target = 'class-b' | ||
const contents = ['const Button = styled.button`class-a ', target, '`'] | ||
expectClassPosition(target, contents, 'tsx') | ||
}) | ||
|
||
test('styled template literal and new lines', () => { | ||
const target = 'class-b' | ||
const contents = [dedent` | ||
const Button = styled | ||
.button\`class-a `, target, '`'] | ||
expectClassPosition(target, contents, 'tsx') | ||
}) | ||
|
||
test('styled invoked', () => { | ||
const target = 'class-b' | ||
const contents = ['const Button = styled.button("class-a ', target, '")'] | ||
expectClassPosition(target, contents, 'tsx') | ||
}) |
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