chore: use prettier instead of clang-format (#7014)

* chore: add and configure prettier

* chore: remove clang-format

* chore: remove clang-format config

* chore: lint additional ts files

* chore: fix lint errors in blocks

* chore: add prettier-ignore where needed

* chore: ignore js blocks when formatting

* chore: fix playground html syntax

* chore: fix yaml spacing from merge

* chore: convert text blocks to use arrow functions

* chore: format everything with prettier

* chore: fix lint unused imports in blocks
This commit is contained in:
Maribeth Bottorff
2023-05-10 16:01:39 -07:00
committed by GitHub
parent af991f5e1b
commit 88ff901a72
425 changed files with 29170 additions and 21169 deletions

View File

@@ -18,8 +18,6 @@ const fs = require('fs');
const {exec, execSync} = require('child_process');
const through2 = require('through2');
const clangFormat = require('clang-format');
const clangFormatter = require('gulp-clang-format');
const closureCompiler = require('google-closure-compiler').gulp();
const closureDeps = require('google-closure-deps');
const argv = require('yargs').argv;
@@ -717,19 +715,6 @@ function cleanBuildDir() {
return rimraf(BUILD_DIR);
}
/**
* Runs clang format on all files in the core directory.
*/
function format() {
return gulp.src([
'core/**/*.js', 'core/**/*.ts',
'blocks/**/*.js', 'blocks/**/*.ts',
'.eslintrc.js'
], {base: '.'})
.pipe(clangFormatter.format('file', clangFormat))
.pipe(gulp.dest('.'));
}
// Main sequence targets. Each should invoke any immediate prerequisite(s).
exports.cleanBuildDir = cleanBuildDir;
exports.langfiles = buildLangfiles; // Build build/msg/*.js from msg/json/*.
@@ -739,7 +724,6 @@ exports.minify = gulp.series(exports.deps, buildCompiled);
exports.build = gulp.parallel(exports.minify, exports.langfiles);
// Manually-invokable targets, with prerequisites where required.
exports.format = format;
exports.messages = generateMessages; // Generate msg/json/en.json et al.
exports.buildAdvancedCompilationTest =
gulp.series(exports.deps, buildAdvancedCompilationTest);

View File

@@ -13,7 +13,8 @@
{
// Example entry:
'0.0.0': [ // Version that includes the rename.
'0.0.0': [
// Version that includes the rename.
// Each entry in the array is a module.
// All of the properties are optional.
{
@@ -100,7 +101,7 @@
newExport: 'conditionalBind',
},
},
}
},
],
'7.20211209.0-beta.0': [
@@ -162,20 +163,20 @@
getMethod: 'getSelected',
setMethod: 'setSelected',
},
}
},
},
{
oldName: 'Blockly.Blocks',
newName: 'Blockly.blocks',
newExport: 'Blocks', // Previous default export now named.
newPath: 'Blockly.Blocks', // But still on tree with original name.
newExport: 'Blocks', // Previous default export now named.
newPath: 'Blockly.Blocks', // But still on tree with original name.
},
{
oldName: 'Blockly.ContextMenu',
exports: {
currentBlock: {
getMethod: 'getCurrentBlock',
setMethod: 'setCurrentBlock'
setMethod: 'setCurrentBlock',
},
},
},
@@ -201,8 +202,8 @@
{
oldName: 'Blockly.connectionTypes',
newName: 'Blockly.ConnectionType',
newExport: 'ConnectionType', // Previous default export now named.
newPath: 'Blockly.ConnectionType', // Type reexported directly.
newExport: 'ConnectionType', // Previous default export now named.
newPath: 'Blockly.ConnectionType', // Type reexported directly.
},
{
oldName: 'Blockly.utils',
@@ -258,37 +259,37 @@
resizeSvgContents: {newModule: 'Blockly.WorkspaecSvg'},
defineBlocksWithJsonArray: {newModule: 'Blockly.common'},
isNumber: {newModule: 'Blockly.utils.string'},
}
},
},
{
oldName: 'Blockly.Blocks.colour',
newName: 'Blockly.blocks.colour'
newName: 'Blockly.blocks.colour',
},
// Blockly.Blocks.lists not previously provided.
{
oldName: 'Blockly.Blocks.logic',
newName: 'Blockly.blocks.logic'
newName: 'Blockly.blocks.logic',
},
{
oldName: 'Blockly.Blocks.loops',
newName: 'Blockly.blocks.loops'
newName: 'Blockly.blocks.loops',
},
{
oldName: 'Blockly.Blocks.math',
newName: 'Blockly.blocks.math'
newName: 'Blockly.blocks.math',
},
{
oldName: 'Blockly.Blocks.procedures',
newName: 'Blockly.blocks.procedures'
newName: 'Blockly.blocks.procedures',
},
{
oldName: 'Blockly.Blocks.texts',
newName: 'Blockly.blocks.texts'
newName: 'Blockly.blocks.texts',
},
{
oldName: 'Blockly.Blocks.variables',
newName: 'Blockly.blocks.variables'
newName: 'Blockly.blocks.variables',
},
// Blockly.Blocks.variablesDynamic not previously provided.
@@ -302,7 +303,7 @@
getRelativeXY: {newModule: 'Blockly.utils.svgMath'},
getInjectionDivXY_: {
newModule: 'Blockly.utils.svgMath',
newExport: 'getInjectionDivXY'
newExport: 'getInjectionDivXY',
},
parseBlockColour: {newModule: 'Blockly.utils.parsing'},
checkMessageReferences: {newModule: 'Blockly.utils.parsing'},
@@ -310,12 +311,16 @@
tokenizeInterpolation: {newModule: 'Blockly.utils.parsing'},
arrayRemove: {
newModule: 'Blockly.utils.array',
newExport: 'removeElem'
newExport: 'removeElem',
},
getBlockTypeCounts: {
newModule: 'Blockly.common',
newExport: 'getBlockTypeCounts',
},
runAfterPageLoad: {
newModule: 'Blockly.Extensions',
newExport: 'runAfterPageLoad',
},
getBlockTypeCounts:
{newModule: 'Blockly.common', newExport: 'getBlockTypeCounts'},
runAfterPageLoad:
{newModule: 'Blockly.Extensions', newExport: 'runAfterPageLoad'},
},
},
@@ -1344,8 +1349,8 @@
globalThis: {
oldPath: 'Blockly.utils.global',
newPath: 'globalThis',
}
}
},
},
},
{
oldName: 'Blockly.Dart',
@@ -1437,7 +1442,7 @@
newModule: 'Blockly.utils.xml',
},
},
}
},
],
'develop': [

View File

@@ -1,20 +1,22 @@
# Blockly
Google's Blockly is a web-based, visual programming editor. Users can drag
blocks together to build programs. All code is free and open source.
Google's Blockly is a web-based, visual programming editor. Users can drag
blocks together to build programs. All code is free and open source.
The source for this module is in the [Blockly repo](http://github.com/google/blockly).
## Installation
You can install this package either via ``npm`` or ``unpkg``.
You can install this package either via `npm` or `unpkg`.
### npm
```bash
npm install blockly
```
### unpkg
```html
<script src="https://unpkg.com/blockly/blockly.min.js"></script>
```
@@ -32,10 +34,9 @@ Blockly.inject('blocklyDiv', {
For samples on how to integrate Blockly into your project, view the list of samples at [blockly-samples](https://github.com/google/blockly-samples).
### Importing Blockly
When you import Blockly with ``import * as Blockly from 'blockly';`` you'll get the default modules:
When you import Blockly with `import * as Blockly from 'blockly';` you'll get the default modules:
Blockly core, Blockly built-in blocks, the JavaScript generator and the English lang files.
If you need more flexibility, you'll want to define your imports more carefully:
@@ -49,15 +50,17 @@ import * as Blockly from 'blockly/core';
#### Blockly built in blocks
```js
import * as libraryBlocks from 'blockly/blocks';
import * as libraryBlocks from 'blockly/blocks';
```
#### Blockly Generators
If your application needs to generate code from the Blockly blocks, you'll want to include a generator.
```js
import {pythonGenerator} from 'blockly/python';
```
to include the Python generator. You can also import `{javascriptGenerator} from 'blockly/javascript'`, `{phpGenerator} from 'blockly/php'`, `{dartGenerator} from 'blockly/dart'` and `{luaGenerator} from 'blockly/lua'`.
#### Blockly Languages
@@ -71,7 +74,6 @@ To import the French lang files. Once you've imported the specific lang module,
For a full list of supported Blockly locales, see: [https://github.com/google/blockly/tree/master/msg/js](https://github.com/google/blockly/tree/master/msg/js)
## License
Apache 2.0

View File

@@ -11,4 +11,3 @@
/* eslint-disable */
'use strict';

View File

@@ -12,7 +12,6 @@
/* eslint-disable */
'use strict';
// Override textToDomDocument and provide Node.js alternatives to DOMParser and
// XMLSerializer.
if (typeof globalThis.document !== 'object') {

View File

@@ -1,11 +1,11 @@
{
"colour":"#A5745B",
"lists":"260",
"logic":"210",
"loops":"120",
"math":"230",
"procedure":"290",
"text":"160",
"variables":"310",
"variables_dynamic":"310"
"colour": "#A5745B",
"lists": "260",
"logic": "210",
"loops": "120",
"math": "230",
"procedure": "290",
"text": "160",
"variables": "310",
"variables_dynamic": "310"
}

View File

@@ -60,7 +60,10 @@ function rewriteEnum(code) {
// (function (names) {
// ...
// })(names || (names = {}));
const enumDefs = code.match(/\s+\(function \((\w+)\) \{\n[^}]*\}\)\(\1 [^)]+\1 = \{\}\)\);/g) || [];
const enumDefs =
code.match(
/\s+\(function \((\w+)\) \{\n[^}]*\}\)\(\1 [^)]+\1 = \{\}\)\);/g
) || [];
for (const oldEnumDef of enumDefs) {
// enumDef looks like a bunch of lines in one of these two formats:
// ScopeType["BLOCK"] = "block";