dav*_*esp 4 npm react-native visual-studio-code expo
我将以下React Native项目导入到VS Code.
https://github.com/callstack/react-native-paper/tree/master/example
然后,在以下文件的第 15 行:
https://github.com/callstack/react-native-paper/blob/master/example/src/CardExample.js#L15
我添加了(只是试验)这一行:
import { StatusBar, I18nManager, AsyncStorage } from 'react-native';
Run Code Online (Sandbox Code Playgroud)
正如您在下面的代码中看到的:
/* @flow */
import * as React from 'react';
import { Alert, ScrollView, StyleSheet } from 'react-native';
import {
Title,
Caption,
Paragraph,
Card,
Button,
withTheme,
type Theme,
} from 'react-native-paper';
import { StatusBar, I18nManager, AsyncStorage } from 'react-native';
type Props = {
theme: Theme,
};
class CardExample extends React.Component<Props> {
static title = 'Card';
render() {
const {
theme: {
colors: { background },
},
} = this.props;
return (
<ScrollView
style={[styles.container, { backgroundColor: background }]}
contentContainerStyle={styles.content}
>
<Card style={styles.card}>
<Card.Cover source={require('../assets/wrecked-ship.jpg')} />
<Card.Content>
<Title>Abandoned Ship</Title>
<Paragraph>
The Abandoned Ship is a wrecked ship located on Route 108 in
Hoenn, originally being a ship named the S.S. Cactus. The second
part of the ship can only be accessed by using Dive and contains
the Scanner.
</Paragraph>
</Card.Content>
</Card>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
content: {
padding: 4,
},
card: {
margin: 4,
},
});
export default withTheme(CardExample);
Run Code Online (Sandbox Code Playgroud)
我的问题是,VS Code未使用未使用的导入的新行不会变灰或突出显示,如下图所示:
React Native有没有一种简单的方法可以让我通过将这些导入灰显或npm在命令行上运行一些命令来了解该项目中未使用的导入?
谢谢!
我建议使用 eslint。
有关安装说明,请参阅:https://medium.com/@deadcoder0904/eslint-setup-in-react-native-using-vscode-c3122a1da9c7
它将标记未使用的导入
| 归档时间: |
|
| 查看次数: |
4828 次 |
| 最近记录: |