Parcourir la source

Update `printWidth` to 100

Alex Dima il y a 4 ans
Parent
commit
c5586a25cf

+ 7 - 0
.prettierignore

@@ -0,0 +1,7 @@
+/browser-esm-parcel/.cache/
+/browser-esm-parcel/dist/
+/browser-esm-webpack/dist/*.js
+/browser-esm-webpack-monaco-plugin/dist/*.js
+/browser-esm-webpack-small/dist/*.js
+/browser-esm-webpack-typescript/dist/*.js
+/browser-esm-webpack-typescript-react/dist/*.js

+ 2 - 1
.prettierrc

@@ -3,5 +3,6 @@
 	"singleQuote": true,
 	"trailingComma": "none",
 	"semi": true,
-	"useTabs": true
+	"useTabs": true,
+	"printWidth": 100
 }

+ 4 - 14
browser-amd-diff-editor/index.html

@@ -5,23 +5,16 @@
 	</head>
 	<body>
 		<h2>Monaco Diff Editor Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
 		<script>
 			require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
 
 			require(['vs/editor/editor.main'], function () {
-				var diffEditor = monaco.editor.createDiffEditor(
-					document.getElementById('container')
-				);
+				var diffEditor = monaco.editor.createDiffEditor(document.getElementById('container'));
 
-				Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function (
-					r
-				) {
+				Promise.all([xhr('original.txt'), xhr('modified.txt')]).then(function (r) {
 					var originalTxt = r[0].responseText;
 					var modifiedTxt = r[1].responseText;
 
@@ -44,10 +37,7 @@
 							}
 
 							if (req.readyState === 4) {
-								if (
-									(req.status >= 200 && req.status < 300) ||
-									req.status === 1223
-								) {
+								if ((req.status >= 200 && req.status < 300) || req.status === 1223) {
 									c(req);
 								} else {
 									e(req);

+ 5 - 15
browser-amd-editor/index.html

@@ -6,10 +6,7 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
@@ -17,17 +14,10 @@
 			require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
 
 			require(['vs/editor/editor.main'], function () {
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						value: [
-							'function x() {',
-							'\tconsole.log("Hello world!");',
-							'}'
-						].join('\n'),
-						language: 'javascript'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+					language: 'javascript'
+				});
 			});
 		</script>
 	</body>

+ 4 - 11
browser-amd-iframe/inner.html

@@ -20,17 +20,10 @@
 			require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
 
 			require(['vs/editor/editor.main'], function () {
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						value: [
-							'function x() {',
-							'\tconsole.log("Hello world!");',
-							'}'
-						].join('\n'),
-						language: 'javascript'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+					language: 'javascript'
+				});
 
 				window.onresize = function () {
 					editor.layout();

+ 5 - 15
browser-amd-localized/index.html

@@ -5,10 +5,7 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Localization Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
 		<script>
@@ -23,17 +20,10 @@
 			});
 
 			require(['vs/editor/editor.main'], function () {
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						value: [
-							'function x() {',
-							'\tconsole.log("Hello world!");',
-							'}'
-						].join('\n'),
-						language: 'javascript'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+					language: 'javascript'
+				});
 			});
 		</script>
 	</body>

+ 6 - 12
browser-amd-monarch/index.html

@@ -5,10 +5,7 @@
 	</head>
 	<body>
 		<h2>Monarch Tokenizer Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
 		<script>
@@ -41,14 +38,11 @@
 					]
 				});
 
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						theme: 'myCoolTheme',
-						value: getCode(),
-						language: 'myCustomLanguage'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					theme: 'myCoolTheme',
+					value: getCode(),
+					language: 'myCustomLanguage'
+				});
 			});
 
 			function getCode() {

+ 5 - 15
browser-amd-requirejs/index.html

@@ -5,10 +5,7 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Sample - Loading with requirejs</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<script
 			src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"
@@ -19,17 +16,10 @@
 			require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
 
 			require(['vs/editor/editor.main'], function () {
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						value: [
-							'function x() {',
-							'\tconsole.log("Hello world!");',
-							'}'
-						].join('\n'),
-						language: 'javascript'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+					language: 'javascript'
+				});
 			});
 		</script>
 	</body>

+ 2 - 7
browser-amd-shadow-dom/index.html

@@ -14,10 +14,7 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<!-- OR ANY OTHER AMD LOADER HERE INSTEAD OF loader.js -->
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
@@ -44,9 +41,7 @@
 
 			require(['vs/editor/editor.main'], function () {
 				const editor = monaco.editor.create(innerContainer, {
-					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-						'\n'
-					),
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 					language: 'javascript'
 				});
 			});

+ 8 - 20
browser-amd-shared-model/index.html

@@ -5,14 +5,8 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Shared Models Sample</h2>
-		<div
-			id="container1"
-			style="width: 400px; height: 200px; border: 1px solid grey"
-		></div>
-		<div
-			id="container2"
-			style="width: 400px; height: 200px; border: 1px solid grey"
-		></div>
+		<div id="container1" style="width: 400px; height: 200px; border: 1px solid grey"></div>
+		<div id="container2" style="width: 400px; height: 200px; border: 1px solid grey"></div>
 
 		<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
 		<script>
@@ -23,18 +17,12 @@
 					['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 					'javascript'
 				);
-				var editor1 = monaco.editor.create(
-					document.getElementById('container1'),
-					{
-						model: model
-					}
-				);
-				var editor2 = monaco.editor.create(
-					document.getElementById('container2'),
-					{
-						model: model
-					}
-				);
+				var editor1 = monaco.editor.create(document.getElementById('container1'), {
+					model: model
+				});
+				var editor2 = monaco.editor.create(document.getElementById('container2'), {
+					model: model
+				});
 			});
 		</script>
 	</body>

+ 1 - 4
browser-esm-parcel/src/index.html

@@ -4,10 +4,7 @@
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 	</head>
 	<body>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid #ccc"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
 
 		<script src="index.js"></script>
 	</body>

+ 1 - 4
browser-esm-webpack-small/dist/index.html

@@ -4,10 +4,7 @@
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 	</head>
 	<body>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid #ccc"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
 
 		<script src="./app.bundle.js"></script>
 	</body>

+ 5 - 19
browser-esm-webpack-small/generate-imports.js

@@ -27,9 +27,7 @@ function getBasicLanguages() {
 
 				resolve(
 					files.map((file) => {
-						return file
-							.substring('./node_modules/monaco-editor/esm/'.length)
-							.replace(/\.js$/, '');
+						return file.substring('./node_modules/monaco-editor/esm/'.length).replace(/\.js$/, '');
 					})
 				);
 			}
@@ -53,14 +51,8 @@ function getAdvancedLanguages() {
 
 				resolve(
 					files
-						.map((file) =>
-							file.substring(
-								'./node_modules/monaco-editor/esm/vs/language/'.length
-							)
-						)
-						.map((file) =>
-							file.substring(0, file.length - '/monaco.contribution.js'.length)
-						)
+						.map((file) => file.substring('./node_modules/monaco-editor/esm/vs/language/'.length))
+						.map((file) => file.substring(0, file.length - '/monaco.contribution.js'.length))
 						.map((lang) => `vs/language/${lang}/monaco.contribution`)
 				);
 			}
@@ -115,18 +107,12 @@ function generateFeatures() {
 	const files =
 		fs
 			.readFileSync(
-				path.join(
-					__dirname,
-					'../node_modules/monaco-editor/esm/vs/editor/edcore.main.js'
-				)
+				path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/edcore.main.js')
 			)
 			.toString() +
 		fs
 			.readFileSync(
-				path.join(
-					__dirname,
-					'../node_modules/monaco-editor/esm/vs/editor/editor.all.js'
-				)
+				path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/editor.all.js')
 			)
 			.toString();
 	files.split(/\r\n|\n/).forEach((line) => {

+ 1 - 3
browser-esm-webpack-typescript-react/src/components/Editor.tsx

@@ -26,9 +26,7 @@ export const Editor: React.FC = () => {
 	useEffect(() => {
 		if (divEl.current) {
 			editor = monaco.editor.create(divEl.current, {
-				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-					'\n'
-				),
+				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 				language: 'typescript'
 			});
 		}

+ 2 - 8
browser-esm-webpack-typescript-react/webpack.config.js

@@ -34,14 +34,8 @@ module.exports = {
 					{
 						loader: require.resolve('babel-loader'),
 						options: {
-							presets: [
-								'@babel/preset-env',
-								'@babel/preset-typescript',
-								'@babel/preset-react'
-							],
-							plugins: [
-								isDevelopment && require.resolve('react-refresh/babel')
-							].filter(Boolean)
+							presets: ['@babel/preset-env', '@babel/preset-typescript', '@babel/preset-react'],
+							plugins: [isDevelopment && require.resolve('react-refresh/babel')].filter(Boolean)
 						}
 					}
 				]

+ 1 - 4
browser-esm-webpack/dist/index.html

@@ -4,10 +4,7 @@
 		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
 	</head>
 	<body>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid #ccc"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
 
 		<script src="./app.bundle.js"></script>
 	</body>

+ 2 - 7
browser-script-editor/index.html

@@ -10,10 +10,7 @@
 	</head>
 	<body>
 		<h2>Monaco Editor Sync Loading Sample</h2>
-		<div
-			id="container"
-			style="width: 800px; height: 600px; border: 1px solid grey"
-		></div>
+		<div id="container" style="width: 800px; height: 600px; border: 1px solid grey"></div>
 
 		<script>
 			var require = { paths: { vs: '../node_modules/monaco-editor/min/vs' } };
@@ -24,9 +21,7 @@
 
 		<script>
 			var editor = monaco.editor.create(document.getElementById('container'), {
-				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-					'\n'
-				),
+				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 				language: 'javascript'
 			});
 		</script>

+ 7 - 19
electron-amd-nodeIntegration/electron-index.html

@@ -4,16 +4,13 @@
 		<meta charset="UTF-8" />
 		<meta
 			http-equiv="Content-Security-Policy"
-			content="default-src 'none'; script-src file: 'sha256-TtwXDwNf27AqcsOrUpfkC3hkt80RRVrp7Xlab9b0ZVk='; style-src 'unsafe-inline' file:; font-src file:"
+			content="default-src 'none'; script-src file: 'sha256-RtE3AqQ1tBhtcwykhJsEKY7jjCqiGy5yH1mRDwu6gEE='; style-src 'unsafe-inline' file:; font-src file:"
 		/>
 		<title>Monaco Editor!</title>
 	</head>
 	<body>
 		<h1>Monaco Editor in Electron!</h1>
-		<div
-			id="container"
-			style="width: 500px; height: 300px; border: 1px solid #ccc"
-		></div>
+		<div id="container" style="width: 500px; height: 300px; border: 1px solid #ccc"></div>
 	</body>
 
 	<script>
@@ -32,26 +29,17 @@
 			}
 
 			amdRequire.config({
-				baseUrl: uriFromPath(
-					path.join(__dirname, '../node_modules/monaco-editor/min')
-				)
+				baseUrl: uriFromPath(path.join(__dirname, '../node_modules/monaco-editor/min'))
 			});
 
 			// workaround monaco-css not understanding the environment
 			self.module = undefined;
 
 			amdRequire(['vs/editor/editor.main'], function () {
-				var editor = monaco.editor.create(
-					document.getElementById('container'),
-					{
-						value: [
-							'function x() {',
-							'\tconsole.log("Hello world!");',
-							'}'
-						].join('\n'),
-						language: 'javascript'
-					}
-				);
+				var editor = monaco.editor.create(document.getElementById('container'), {
+					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+					language: 'javascript'
+				});
 			});
 		})();
 	</script>

+ 1 - 3
electron-amd-nodeIntegration/index.html

@@ -7,9 +7,7 @@
 		<h2>Monaco Editor Electron Sample</h2>
 
 		To run this sample, you need to
-		<a href="https://github.com/electron/electron/releases"
-			>download Electron</a
-		>
+		<a href="https://github.com/electron/electron/releases">download Electron</a>
 		and then execute:
 
 		<pre>

+ 7 - 13
electron-amd/electron-index.html

@@ -4,7 +4,7 @@
 		<meta charset="UTF-8" />
 		<meta
 			http-equiv="Content-Security-Policy"
-			content="default-src 'none'; script-src file: 'sha256-eUe9D+bk6Fb37s7QPlaxhnIImIQEcnZ1gE7aRcB3yOM='; style-src 'unsafe-inline' file:; font-src file:"
+			content="default-src 'none'; script-src file: 'sha256-AcqnkP3xWRYJaQ27hijK3b831+qsxvzEoSYt6PfGrRE='; style-src 'unsafe-inline' file:; font-src file:"
 		/>
 		<title>Monaco Editor!</title>
 		<style>
@@ -18,9 +18,8 @@
 
 	<body>
 		<h1>Monaco Editor in Electron (without nodeIntegration)!</h1>
-		Note: Since Electron without nodeIntegration is very similar to a browser,
-		you can have a look at all the other `browser-` samples, as they should work
-		just fine. <br /><br />
+		Note: Since Electron without nodeIntegration is very similar to a browser, you can have a look
+		at all the other `browser-` samples, as they should work just fine. <br /><br />
 		<div id="container"></div>
 	</body>
 
@@ -29,15 +28,10 @@
 		require.config({ paths: { vs: '../node_modules/monaco-editor/min/vs' } });
 
 		require(['vs/editor/editor.main'], function () {
-			const editor = monaco.editor.create(
-				document.getElementById('container'),
-				{
-					value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-						'\n'
-					),
-					language: 'javascript'
-				}
-			);
+			const editor = monaco.editor.create(document.getElementById('container'), {
+				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
+				language: 'javascript'
+			});
 		});
 	</script>
 </html>

+ 1 - 3
electron-amd/index.html

@@ -7,9 +7,7 @@
 		<h2>Monaco Editor Electron Sample</h2>
 
 		To run this sample, you need to
-		<a href="https://github.com/electron/electron/releases"
-			>download Electron</a
-		>
+		<a href="https://github.com/electron/electron/releases">download Electron</a>
 		and then execute:
 
 		<pre>

+ 1 - 3
nwjs-amd-v2/index.html

@@ -48,9 +48,7 @@
 		self.process.browser = true;
 		ERequire(['vs/editor/editor.main'], function () {
 			var editor = monaco.editor.create(document.getElementById('container'), {
-				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-					'\n'
-				),
+				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 				language: 'javascript',
 				theme: 'vs-dark'
 			});

+ 2 - 7
nwjs-amd/index.html

@@ -11,10 +11,7 @@
 	</head>
 	<body>
 		<h1>Hello World!</h1>
-		<div
-			id="container"
-			style="width: 500px; height: 300px; border: 1px solid #ccc"
-		></div>
+		<div id="container" style="width: 500px; height: 300px; border: 1px solid #ccc"></div>
 	</body>
 
 	<script>
@@ -43,9 +40,7 @@
 
 		amdRequire(['vs/editor/editor.main'], function () {
 			var editor = monaco.editor.create(document.getElementById('container'), {
-				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join(
-					'\n'
-				),
+				value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
 				language: 'javascript'
 			});
 		});

+ 1 - 0
package.json

@@ -4,6 +4,7 @@
 	"description": "Samples for using the Monaco Editor",
 	"main": "index.js",
 	"scripts": {
+		"prettier": "prettier --write .",
 		"simpleserver": "yaserver --root ./ --port 8888"
 	},
 	"author": "Microsoft Corporation",