質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
ESLint

ESLintは、JavaScriptのための構文チェックツール。全検証ルールを自由に on/offでき、独自のプロジェクトに合わせたカスタムルールを容易に設定することが可能。公開されている様々なプラグインを組み込んで使用することもできます。

React Native

React Nativeは、ネイティブモバイルアプリ(iOS/Android)を作成できるJavaScriptフレームワークです。Reactと同じ設計のため、宣言的なコンポーネントでリッチなUIを開発することが可能です。

JSON

JSON(JavaScript Object Notation)は軽量なデータ記述言語の1つである。構文はJavaScriptをベースとしていますが、JavaScriptに限定されたものではなく、様々なソフトウェアやプログラミング言語間におけるデータの受け渡しが行えるように設計されています。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

Q&A

0回答

1233閲覧

react native をvscodeで書くときのコード整形について(pretter,eslint,setting.json)の設定について教えて下さい!

asai569

総合スコア24

ESLint

ESLintは、JavaScriptのための構文チェックツール。全検証ルールを自由に on/offでき、独自のプロジェクトに合わせたカスタムルールを容易に設定することが可能。公開されている様々なプラグインを組み込んで使用することもできます。

React Native

React Nativeは、ネイティブモバイルアプリ(iOS/Android)を作成できるJavaScriptフレームワークです。Reactと同じ設計のため、宣言的なコンポーネントでリッチなUIを開発することが可能です。

JSON

JSON(JavaScript Object Notation)は軽量なデータ記述言語の1つである。構文はJavaScriptをベースとしていますが、JavaScriptに限定されたものではなく、様々なソフトウェアやプログラミング言語間におけるデータの受け渡しが行えるように設計されています。

Visual Studio

Microsoft Visual StudioはMicrosoftによる統合開発環境(IDE)です。多種多様なプログラミング言語に対応しています。

React.js

Reactは、アプリケーションのインターフェースを構築するためのオープンソースJavaScriptライブラリです。

0グッド

1クリップ

投稿2020/02/23 08:56

前提・実現したいこと

vscodeでreact nativeを書きているのですが括弧の後に改行や空白が入りうまくかけません。
pretterと eslint を入れました.コードを整形して書きやすくしたかったのです。
ですが、、

//.eslintrc.js module.exports = { root: true, plugins: ['react'], extends: ["airbnb", '@react-native-community', ' plugin:prettier/recommended', ], parser: 'babel-eslint', // JSXとかでエラー出るのを回避。env の es6:true もこれにより不要になる parserOptions: { sourceType: 'module', // import などを使うときに必要 ecmaFeatures: { experimentalObjectRestSpread: true, // 非推奨項目も注意してくれる?(あんまよくわかってない) jsx: true, //JSX を使うときに必要( reactプラグインいれてるからいらないかも...? ) }, }, };
//.prettierrc.js module.exports = { "trailingComma": "es5", "singleQuote": true };

vscodeのsetting.jsonは下記の様です

{ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "breadcrumbs.enabled": true, "javascript.format.enable": false, // "editor.wordWrap": "on", "files.autoSave": "onFocusChange", "prettier.eslintIntegration": true }

発生している問題・エラーメッセージ

//app.js /** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; const App: () => React$Node = () => { return ( < > < StatusBar barStyle = "dark-content" / > < SafeAreaView > < ScrollView contentInsetAdjustmentBehavior = "automatic" style = { styles.scrollView } > < Header / > { global.HermesInternal == null ? null : ( < View style = { styles.engine } > < Text style = { styles.footer } > Engine: Hermes < /Text> < /View> ) } < View style = { styles.body } > < View style = { styles.sectionContainer } > < Text style = { styles.sectionTitle } > Step One < /Text> < Text style = { styles.sectionDescription } > Edit < Text style = { styles.highlight } > App.js < /Text> to change this screen and then come back to see your edits. < /Text> < /View> < View style = { styles.sectionContainer } > < Text style = { styles.sectionTitle } > See Your Changes < /Text> < Text style = { styles.sectionDescription } > < ReloadInstructions / > < /Text> < /View> < View style = { styles.sectionContainer } > < Text style = { styles.sectionTitle } > Debug < /Text> < Text style = { styles.sectionDescription } > < DebugInstructions / > < /Text> < /View> < View style = { styles.sectionContainer } > < Text style = { styles.sectionTitle } > Learn More < /Text> < Text style = { styles.sectionDescription } > Read the docs to discover what to do next: < /Text> < /View> < LearnMoreLinks / > < /View> < /ScrollView> < /SafeAreaView> < /> ); }; const styles = StyleSheet.create({ scrollView: { backgroundColor: Colors.lighter, }, engine: { position: 'absolute', right: 0, }, body: { backgroundColor: Colors.white, }, sectionContainer: { marginTop: 32, paddingHorizontal: 24, }, sectionTitle: { fontSize: 24, fontWeight: '600', color: Colors.black, }, sectionDescription: { marginTop: 8, fontSize: 18, fontWeight: '400', color: Colors.dark, }, highlight: { fontWeight: '700', }, footer: { color: Colors.dark, fontSize: 12, fontWeight: '600', padding: 4, paddingRight: 12, textAlign: 'right', }, }); export default App;

該当のソースコード

下記のようにしたいのですが、保存時に上記の様になっています。

/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; const App: () => React$Node = () => { return ( <> <StatusBar barStyle="dark-content" /> <SafeAreaView> <ScrollView contentInsetAdjustmentBehavior="automatic" style={styles.scrollView}> <Header /> {global.HermesInternal == null ? null : ( <View style={styles.engine}> <Text style={styles.footer}>Engine: Hermes</Text> </View> )} <View style={styles.body}> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>Step One</Text> <Text style={styles.sectionDescription}> Edit <Text style={styles.highlight}>App.js</Text> to change this screen and then come back to see your edits. </Text> </View> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>See Your Changes</Text> <Text style={styles.sectionDescription}> <ReloadInstructions /> </Text> </View> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>Debug</Text> <Text style={styles.sectionDescription}> <DebugInstructions /> </Text> </View> <View style={styles.sectionContainer}> <Text style={styles.sectionTitle}>Learn More</Text> <Text style={styles.sectionDescription}> Read the docs to discover what to do next: </Text> </View> <LearnMoreLinks /> </View> </ScrollView> </SafeAreaView> </> ); }; const styles = StyleSheet.create({ scrollView: { backgroundColor: Colors.lighter, }, engine: { position: 'absolute', right: 0, }, body: { backgroundColor: Colors.white, }, sectionContainer: { marginTop: 32, paddingHorizontal: 24, }, sectionTitle: { fontSize: 24, fontWeight: '600', color: Colors.black, }, sectionDescription: { marginTop: 8, fontSize: 18, fontWeight: '400', color: Colors.dark, }, highlight: { fontWeight: '700', }, footer: { color: Colors.dark, fontSize: 12, fontWeight: '600', padding: 4, paddingRight: 12, textAlign: 'right', }, }); export default App;

試したこと

eslintとpretterのインストールしてあります

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問