prettier 1.6.1 → 2.0.0.pre.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +316 -293
- data/CONTRIBUTING.md +6 -9
- data/LICENSE +1 -1
- data/README.md +11 -12
- data/dist/haml/embed.js +53 -0
- data/dist/haml/parser.js +31 -0
- data/{src → dist}/haml/parser.rb +0 -0
- data/dist/haml/printer.js +336 -0
- data/dist/parser/getInfo.js +17 -0
- data/{src → dist}/parser/netcat.js +1 -0
- data/dist/parser/parseSync.js +128 -0
- data/dist/parser/server.rb +140 -0
- data/dist/plugin.js +143 -0
- data/dist/prettier.js +15 -0
- data/dist/rbs/parser.js +34 -0
- data/{src → dist}/rbs/parser.rb +0 -0
- data/dist/rbs/printer.js +517 -0
- data/dist/ruby/embed.js +110 -0
- data/dist/ruby/nodes/alias.js +59 -0
- data/{src → dist}/ruby/nodes/aref.js +26 -35
- data/dist/ruby/nodes/args.js +165 -0
- data/dist/ruby/nodes/arrays.js +126 -0
- data/dist/ruby/nodes/assign.js +41 -0
- data/dist/ruby/nodes/blocks.js +68 -0
- data/dist/ruby/nodes/calls.js +220 -0
- data/dist/ruby/nodes/case.js +50 -0
- data/dist/ruby/nodes/class.js +54 -0
- data/dist/ruby/nodes/commands.js +124 -0
- data/dist/ruby/nodes/conditionals.js +242 -0
- data/dist/ruby/nodes/constants.js +38 -0
- data/dist/ruby/nodes/flow.js +66 -0
- data/dist/ruby/nodes/hashes.js +130 -0
- data/dist/ruby/nodes/heredocs.js +30 -0
- data/dist/ruby/nodes/hooks.js +35 -0
- data/dist/ruby/nodes/ints.js +27 -0
- data/dist/ruby/nodes/lambdas.js +69 -0
- data/dist/ruby/nodes/loops.js +73 -0
- data/dist/ruby/nodes/massign.js +73 -0
- data/dist/ruby/nodes/methods.js +70 -0
- data/dist/ruby/nodes/operators.js +70 -0
- data/dist/ruby/nodes/params.js +89 -0
- data/dist/ruby/nodes/patterns.js +109 -0
- data/dist/ruby/nodes/regexp.js +45 -0
- data/dist/ruby/nodes/rescue.js +82 -0
- data/dist/ruby/nodes/return.js +75 -0
- data/dist/ruby/nodes/statements.js +111 -0
- data/dist/ruby/nodes/strings.js +218 -0
- data/dist/ruby/nodes/super.js +30 -0
- data/dist/ruby/nodes/undef.js +26 -0
- data/dist/ruby/nodes.js +151 -0
- data/dist/ruby/parser.js +34 -0
- data/{src → dist}/ruby/parser.rb +1215 -252
- data/dist/ruby/printer.js +125 -0
- data/dist/ruby/toProc.js +93 -0
- data/dist/types/haml.js +4 -0
- data/dist/types/plugin.js +3 -0
- data/dist/types/rbs.js +4 -0
- data/dist/types/ruby.js +4 -0
- data/dist/types/utils.js +2 -0
- data/dist/types.js +30 -0
- data/dist/utils/containsAssignment.js +15 -0
- data/dist/utils/getTrailingComma.js +6 -0
- data/dist/utils/hasAncestor.js +15 -0
- data/{src → dist}/utils/inlineEnsureParens.js +16 -17
- data/dist/utils/isEmptyBodyStmt.js +10 -0
- data/dist/utils/isEmptyStmts.js +10 -0
- data/dist/utils/literal.js +8 -0
- data/dist/utils/literallineWithoutBreakParent.js +8 -0
- data/dist/utils/makeCall.js +13 -0
- data/dist/utils/noIndent.js +11 -0
- data/dist/utils/printEmptyCollection.js +44 -0
- data/dist/utils/skipAssignIndent.js +15 -0
- data/dist/utils.js +30 -0
- data/node_modules/prettier/bin-prettier.js +313 -190
- data/node_modules/prettier/doc.js +191 -323
- data/node_modules/prettier/index.js +2753 -3677
- data/node_modules/prettier/package.json +1 -1
- data/node_modules/prettier/parser-angular.js +13 -14
- data/node_modules/prettier/parser-babel.js +7 -7
- data/node_modules/prettier/parser-espree.js +7 -7
- data/node_modules/prettier/parser-flow.js +7 -7
- data/node_modules/prettier/parser-glimmer.js +1 -1
- data/node_modules/prettier/parser-graphql.js +1 -1
- data/node_modules/prettier/parser-html.js +17 -17
- data/node_modules/prettier/parser-markdown.js +9 -9
- data/node_modules/prettier/parser-meriyah.js +7 -7
- data/node_modules/prettier/parser-postcss.js +2 -2
- data/node_modules/prettier/parser-typescript.js +7 -7
- data/node_modules/prettier/parser-yaml.js +2 -2
- data/node_modules/prettier/third-party.js +143 -78
- data/package.json +26 -18
- metadata +74 -67
- data/src/haml/embed.js +0 -87
- data/src/haml/parser.js +0 -23
- data/src/haml/printer.js +0 -438
- data/src/parser/parseSync.js +0 -172
- data/src/parser/server.rb +0 -66
- data/src/plugin.js +0 -148
- data/src/prettier.js +0 -16
- data/src/rbs/parser.js +0 -37
- data/src/rbs/printer.js +0 -643
- data/src/ruby/embed.js +0 -142
- data/src/ruby/nodes/alias.js +0 -73
- data/src/ruby/nodes/args.js +0 -222
- data/src/ruby/nodes/arrays.js +0 -162
- data/src/ruby/nodes/assign.js +0 -47
- data/src/ruby/nodes/blocks.js +0 -90
- data/src/ruby/nodes/calls.js +0 -246
- data/src/ruby/nodes/case.js +0 -65
- data/src/ruby/nodes/class.js +0 -64
- data/src/ruby/nodes/commands.js +0 -131
- data/src/ruby/nodes/conditionals.js +0 -282
- data/src/ruby/nodes/constants.js +0 -43
- data/src/ruby/nodes/flow.js +0 -74
- data/src/ruby/nodes/hashes.js +0 -155
- data/src/ruby/nodes/heredocs.js +0 -36
- data/src/ruby/nodes/hooks.js +0 -34
- data/src/ruby/nodes/ints.js +0 -31
- data/src/ruby/nodes/lambdas.js +0 -76
- data/src/ruby/nodes/loops.js +0 -98
- data/src/ruby/nodes/massign.js +0 -98
- data/src/ruby/nodes/methods.js +0 -74
- data/src/ruby/nodes/operators.js +0 -83
- data/src/ruby/nodes/params.js +0 -106
- data/src/ruby/nodes/patterns.js +0 -157
- data/src/ruby/nodes/regexp.js +0 -56
- data/src/ruby/nodes/rescue.js +0 -101
- data/src/ruby/nodes/return.js +0 -94
- data/src/ruby/nodes/statements.js +0 -142
- data/src/ruby/nodes/strings.js +0 -272
- data/src/ruby/nodes/super.js +0 -35
- data/src/ruby/nodes/undef.js +0 -42
- data/src/ruby/nodes.js +0 -34
- data/src/ruby/parser.js +0 -37
- data/src/ruby/printer.js +0 -147
- data/src/ruby/toProc.js +0 -105
- data/src/utils/containsAssignment.js +0 -11
- data/src/utils/getTrailingComma.js +0 -5
- data/src/utils/hasAncestor.js +0 -17
- data/src/utils/isEmptyBodyStmt.js +0 -7
- data/src/utils/isEmptyStmts.js +0 -11
- data/src/utils/literal.js +0 -7
- data/src/utils/literallineWithoutBreakParent.js +0 -7
- data/src/utils/makeCall.js +0 -14
- data/src/utils/noIndent.js +0 -10
- data/src/utils/printEmptyCollection.js +0 -49
- data/src/utils/skipAssignIndent.js +0 -17
- data/src/utils.js +0 -13
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
var os = require('os');
|
4
|
-
var path
|
4
|
+
var path = require('path');
|
5
5
|
var Module = require('module');
|
6
6
|
var fs = require('fs');
|
7
7
|
var util = require('util');
|
@@ -9,7 +9,7 @@ var util = require('util');
|
|
9
9
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
10
10
|
|
11
11
|
var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
|
12
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path
|
12
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
13
13
|
var Module__default = /*#__PURE__*/_interopDefaultLegacy(Module);
|
14
14
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
15
15
|
var util__default = /*#__PURE__*/_interopDefaultLegacy(util);
|
@@ -7716,10 +7716,10 @@ var createPropertyDescriptor = function (bitmap, value) {
|
|
7716
7716
|
};
|
7717
7717
|
};
|
7718
7718
|
|
7719
|
-
var toString = {}.toString;
|
7719
|
+
var toString$1 = {}.toString;
|
7720
7720
|
|
7721
7721
|
var classofRaw = function (it) {
|
7722
|
-
return toString.call(it).slice(8, -1);
|
7722
|
+
return toString$1.call(it).slice(8, -1);
|
7723
7723
|
};
|
7724
7724
|
|
7725
7725
|
var split = ''.split;
|
@@ -7752,19 +7752,94 @@ var isObject = function (it) {
|
|
7752
7752
|
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
7753
7753
|
};
|
7754
7754
|
|
7755
|
-
|
7756
|
-
|
7757
|
-
|
7758
|
-
|
7759
|
-
var
|
7760
|
-
|
7755
|
+
var aFunction$1 = function (variable) {
|
7756
|
+
return typeof variable == 'function' ? variable : undefined;
|
7757
|
+
};
|
7758
|
+
|
7759
|
+
var getBuiltIn = function (namespace, method) {
|
7760
|
+
return arguments.length < 2 ? aFunction$1(global[namespace]) : global[namespace] && global[namespace][method];
|
7761
|
+
};
|
7762
|
+
|
7763
|
+
var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
|
7764
|
+
|
7765
|
+
var process$1 = global.process;
|
7766
|
+
var Deno = global.Deno;
|
7767
|
+
var versions = process$1 && process$1.versions || Deno && Deno.version;
|
7768
|
+
var v8 = versions && versions.v8;
|
7769
|
+
var match, version;
|
7770
|
+
|
7771
|
+
if (v8) {
|
7772
|
+
match = v8.split('.');
|
7773
|
+
version = match[0] < 4 ? 1 : match[0] + match[1];
|
7774
|
+
} else if (engineUserAgent) {
|
7775
|
+
match = engineUserAgent.match(/Edge\/(\d+)/);
|
7776
|
+
if (!match || match[1] >= 74) {
|
7777
|
+
match = engineUserAgent.match(/Chrome\/(\d+)/);
|
7778
|
+
if (match) version = match[1];
|
7779
|
+
}
|
7780
|
+
}
|
7781
|
+
|
7782
|
+
var engineV8Version = version && +version;
|
7783
|
+
|
7784
|
+
/* eslint-disable es/no-symbol -- required for testing */
|
7785
|
+
|
7786
|
+
// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
|
7787
|
+
var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
|
7788
|
+
var symbol = Symbol();
|
7789
|
+
// Chrome 38 Symbol has incorrect toString conversion
|
7790
|
+
// `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
|
7791
|
+
return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
|
7792
|
+
// Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
|
7793
|
+
!Symbol.sham && engineV8Version && engineV8Version < 41;
|
7794
|
+
});
|
7795
|
+
|
7796
|
+
/* eslint-disable es/no-symbol -- required for testing */
|
7797
|
+
|
7798
|
+
var useSymbolAsUid = nativeSymbol
|
7799
|
+
&& !Symbol.sham
|
7800
|
+
&& typeof Symbol.iterator == 'symbol';
|
7801
|
+
|
7802
|
+
var isSymbol = useSymbolAsUid ? function (it) {
|
7803
|
+
return typeof it == 'symbol';
|
7804
|
+
} : function (it) {
|
7805
|
+
var $Symbol = getBuiltIn('Symbol');
|
7806
|
+
return typeof $Symbol == 'function' && Object(it) instanceof $Symbol;
|
7807
|
+
};
|
7808
|
+
|
7809
|
+
// `OrdinaryToPrimitive` abstract operation
|
7810
|
+
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
|
7811
|
+
var ordinaryToPrimitive = function (input, pref) {
|
7761
7812
|
var fn, val;
|
7762
|
-
if (
|
7813
|
+
if (pref === 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
|
7763
7814
|
if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
|
7764
|
-
if (
|
7815
|
+
if (pref !== 'string' && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
|
7765
7816
|
throw TypeError("Can't convert object to primitive value");
|
7766
7817
|
};
|
7767
7818
|
|
7819
|
+
var setGlobal = function (key, value) {
|
7820
|
+
try {
|
7821
|
+
// eslint-disable-next-line es/no-object-defineproperty -- safe
|
7822
|
+
Object.defineProperty(global, key, { value: value, configurable: true, writable: true });
|
7823
|
+
} catch (error) {
|
7824
|
+
global[key] = value;
|
7825
|
+
} return value;
|
7826
|
+
};
|
7827
|
+
|
7828
|
+
var SHARED = '__core-js_shared__';
|
7829
|
+
var store$1 = global[SHARED] || setGlobal(SHARED, {});
|
7830
|
+
|
7831
|
+
var sharedStore = store$1;
|
7832
|
+
|
7833
|
+
var shared = createCommonjsModule(function (module) {
|
7834
|
+
(module.exports = function (key, value) {
|
7835
|
+
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
7836
|
+
})('versions', []).push({
|
7837
|
+
version: '3.17.3',
|
7838
|
+
mode: 'global',
|
7839
|
+
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
|
7840
|
+
});
|
7841
|
+
});
|
7842
|
+
|
7768
7843
|
// `ToObject` abstract operation
|
7769
7844
|
// https://tc39.es/ecma262/#sec-toobject
|
7770
7845
|
var toObject = function (argument) {
|
@@ -7777,6 +7852,52 @@ var has$1 = Object.hasOwn || function hasOwn(it, key) {
|
|
7777
7852
|
return hasOwnProperty.call(toObject(it), key);
|
7778
7853
|
};
|
7779
7854
|
|
7855
|
+
var id = 0;
|
7856
|
+
var postfix = Math.random();
|
7857
|
+
|
7858
|
+
var uid = function (key) {
|
7859
|
+
return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
|
7860
|
+
};
|
7861
|
+
|
7862
|
+
var WellKnownSymbolsStore = shared('wks');
|
7863
|
+
var Symbol$1 = global.Symbol;
|
7864
|
+
var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
|
7865
|
+
|
7866
|
+
var wellKnownSymbol = function (name) {
|
7867
|
+
if (!has$1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
|
7868
|
+
if (nativeSymbol && has$1(Symbol$1, name)) {
|
7869
|
+
WellKnownSymbolsStore[name] = Symbol$1[name];
|
7870
|
+
} else {
|
7871
|
+
WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
|
7872
|
+
}
|
7873
|
+
} return WellKnownSymbolsStore[name];
|
7874
|
+
};
|
7875
|
+
|
7876
|
+
var TO_PRIMITIVE = wellKnownSymbol('toPrimitive');
|
7877
|
+
|
7878
|
+
// `ToPrimitive` abstract operation
|
7879
|
+
// https://tc39.es/ecma262/#sec-toprimitive
|
7880
|
+
var toPrimitive = function (input, pref) {
|
7881
|
+
if (!isObject(input) || isSymbol(input)) return input;
|
7882
|
+
var exoticToPrim = input[TO_PRIMITIVE];
|
7883
|
+
var result;
|
7884
|
+
if (exoticToPrim !== undefined) {
|
7885
|
+
if (pref === undefined) pref = 'default';
|
7886
|
+
result = exoticToPrim.call(input, pref);
|
7887
|
+
if (!isObject(result) || isSymbol(result)) return result;
|
7888
|
+
throw TypeError("Can't convert object to primitive value");
|
7889
|
+
}
|
7890
|
+
if (pref === undefined) pref = 'number';
|
7891
|
+
return ordinaryToPrimitive(input, pref);
|
7892
|
+
};
|
7893
|
+
|
7894
|
+
// `ToPropertyKey` abstract operation
|
7895
|
+
// https://tc39.es/ecma262/#sec-topropertykey
|
7896
|
+
var toPropertyKey = function (argument) {
|
7897
|
+
var key = toPrimitive(argument, 'string');
|
7898
|
+
return isSymbol(key) ? key : String(key);
|
7899
|
+
};
|
7900
|
+
|
7780
7901
|
var document = global.document;
|
7781
7902
|
// typeof document.createElement is 'object' in old IE
|
7782
7903
|
var EXISTS = isObject(document) && isObject(document.createElement);
|
@@ -7800,7 +7921,7 @@ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
7800
7921
|
// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
|
7801
7922
|
var f$3 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
|
7802
7923
|
O = toIndexedObject(O);
|
7803
|
-
P =
|
7924
|
+
P = toPropertyKey(P);
|
7804
7925
|
if (ie8DomDefine) try {
|
7805
7926
|
return $getOwnPropertyDescriptor(O, P);
|
7806
7927
|
} catch (error) { /* empty */ }
|
@@ -7824,7 +7945,7 @@ var $defineProperty = Object.defineProperty;
|
|
7824
7945
|
// https://tc39.es/ecma262/#sec-object.defineproperty
|
7825
7946
|
var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) {
|
7826
7947
|
anObject(O);
|
7827
|
-
P =
|
7948
|
+
P = toPropertyKey(P);
|
7828
7949
|
anObject(Attributes);
|
7829
7950
|
if (ie8DomDefine) try {
|
7830
7951
|
return $defineProperty(O, P, Attributes);
|
@@ -7845,19 +7966,6 @@ var createNonEnumerableProperty = descriptors ? function (object, key, value) {
|
|
7845
7966
|
return object;
|
7846
7967
|
};
|
7847
7968
|
|
7848
|
-
var setGlobal = function (key, value) {
|
7849
|
-
try {
|
7850
|
-
createNonEnumerableProperty(global, key, value);
|
7851
|
-
} catch (error) {
|
7852
|
-
global[key] = value;
|
7853
|
-
} return value;
|
7854
|
-
};
|
7855
|
-
|
7856
|
-
var SHARED = '__core-js_shared__';
|
7857
|
-
var store$1 = global[SHARED] || setGlobal(SHARED, {});
|
7858
|
-
|
7859
|
-
var sharedStore = store$1;
|
7860
|
-
|
7861
7969
|
var functionToString = Function.toString;
|
7862
7970
|
|
7863
7971
|
// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
|
@@ -7873,23 +7981,6 @@ var WeakMap$1 = global.WeakMap;
|
|
7873
7981
|
|
7874
7982
|
var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(inspectSource(WeakMap$1));
|
7875
7983
|
|
7876
|
-
var shared = createCommonjsModule(function (module) {
|
7877
|
-
(module.exports = function (key, value) {
|
7878
|
-
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
|
7879
|
-
})('versions', []).push({
|
7880
|
-
version: '3.14.0',
|
7881
|
-
mode: 'global',
|
7882
|
-
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
|
7883
|
-
});
|
7884
|
-
});
|
7885
|
-
|
7886
|
-
var id = 0;
|
7887
|
-
var postfix = Math.random();
|
7888
|
-
|
7889
|
-
var uid = function (key) {
|
7890
|
-
return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
|
7891
|
-
};
|
7892
|
-
|
7893
7984
|
var keys = shared('keys');
|
7894
7985
|
|
7895
7986
|
var sharedKey = function (key) {
|
@@ -7993,17 +8084,6 @@ var TEMPLATE = String(String).split('String');
|
|
7993
8084
|
});
|
7994
8085
|
});
|
7995
8086
|
|
7996
|
-
var path = global;
|
7997
|
-
|
7998
|
-
var aFunction$1 = function (variable) {
|
7999
|
-
return typeof variable == 'function' ? variable : undefined;
|
8000
|
-
};
|
8001
|
-
|
8002
|
-
var getBuiltIn = function (namespace, method) {
|
8003
|
-
return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global[namespace])
|
8004
|
-
: path[namespace] && path[namespace][method] || global[namespace] && global[namespace][method];
|
8005
|
-
};
|
8006
|
-
|
8007
8087
|
var ceil = Math.ceil;
|
8008
8088
|
var floor$1 = Math.floor;
|
8009
8089
|
|
@@ -8205,6 +8285,11 @@ var aFunction = function (it) {
|
|
8205
8285
|
} return it;
|
8206
8286
|
};
|
8207
8287
|
|
8288
|
+
var toString = function (argument) {
|
8289
|
+
if (isSymbol(argument)) throw TypeError('Cannot convert a Symbol value to a string');
|
8290
|
+
return String(argument);
|
8291
|
+
};
|
8292
|
+
|
8208
8293
|
// TODO: use something more complex like timsort?
|
8209
8294
|
var floor = Math.floor;
|
8210
8295
|
|
@@ -8259,32 +8344,12 @@ var arrayMethodIsStrict = function (METHOD_NAME, argument) {
|
|
8259
8344
|
});
|
8260
8345
|
};
|
8261
8346
|
|
8262
|
-
var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
|
8263
|
-
|
8264
8347
|
var firefox = engineUserAgent.match(/firefox\/(\d+)/i);
|
8265
8348
|
|
8266
8349
|
var engineFfVersion = !!firefox && +firefox[1];
|
8267
8350
|
|
8268
8351
|
var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent);
|
8269
8352
|
|
8270
|
-
var process$1 = global.process;
|
8271
|
-
var versions = process$1 && process$1.versions;
|
8272
|
-
var v8 = versions && versions.v8;
|
8273
|
-
var match, version;
|
8274
|
-
|
8275
|
-
if (v8) {
|
8276
|
-
match = v8.split('.');
|
8277
|
-
version = match[0] < 4 ? 1 : match[0] + match[1];
|
8278
|
-
} else if (engineUserAgent) {
|
8279
|
-
match = engineUserAgent.match(/Edge\/(\d+)/);
|
8280
|
-
if (!match || match[1] >= 74) {
|
8281
|
-
match = engineUserAgent.match(/Chrome\/(\d+)/);
|
8282
|
-
if (match) version = match[1];
|
8283
|
-
}
|
8284
|
-
}
|
8285
|
-
|
8286
|
-
var engineV8Version = version && +version;
|
8287
|
-
|
8288
8353
|
var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./);
|
8289
8354
|
|
8290
8355
|
var engineWebkitVersion = !!webkit && +webkit[1];
|
@@ -8345,7 +8410,7 @@ var getSortCompare = function (comparefn) {
|
|
8345
8410
|
if (y === undefined) return -1;
|
8346
8411
|
if (x === undefined) return 1;
|
8347
8412
|
if (comparefn !== undefined) return +comparefn(x, y) || 0;
|
8348
|
-
return
|
8413
|
+
return toString(x) > toString(y) ? 1 : -1;
|
8349
8414
|
};
|
8350
8415
|
};
|
8351
8416
|
|
@@ -10422,7 +10487,7 @@ async function readFile(filepath, options = {}) {
|
|
10422
10487
|
const content = await fsReadFileAsync(filepath, 'utf8');
|
10423
10488
|
return content;
|
10424
10489
|
} catch (error) {
|
10425
|
-
if (throwNotFound === false && error.code === 'ENOENT') {
|
10490
|
+
if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
|
10426
10491
|
return null;
|
10427
10492
|
}
|
10428
10493
|
|
@@ -10438,7 +10503,7 @@ function readFileSync(filepath, options = {}) {
|
|
10438
10503
|
|
10439
10504
|
return content;
|
10440
10505
|
} catch (error) {
|
10441
|
-
if (throwNotFound === false && error.code === 'ENOENT') {
|
10506
|
+
if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
|
10442
10507
|
return null;
|
10443
10508
|
}
|
10444
10509
|
|
data/package.json
CHANGED
@@ -1,36 +1,46 @@
|
|
1
1
|
{
|
2
2
|
"name": "@prettier/plugin-ruby",
|
3
|
-
"version": "
|
3
|
+
"version": "2.0.0-rc1",
|
4
4
|
"description": "prettier plugin for the Ruby programming language",
|
5
|
-
"main": "
|
5
|
+
"main": "dist/plugin.js",
|
6
6
|
"scripts": {
|
7
|
-
"
|
7
|
+
"checkFormat": "prettier --check '**/*'",
|
8
8
|
"lint": "eslint --cache .",
|
9
|
+
"prepublishOnly": "tsc -p tsconfig.build.json && cp src/parser/getInfo.js dist/parser && cp src/parser/netcat.js dist/parser && cp src/parser/server.rb dist/parser && cp src/haml/parser.rb dist/haml && cp src/rbs/parser.rb dist/rbs && cp src/ruby/parser.rb dist/ruby",
|
9
10
|
"test": "jest"
|
10
11
|
},
|
11
12
|
"repository": {
|
12
13
|
"type": "git",
|
13
14
|
"url": "git+https://github.com/prettier/plugin-ruby.git"
|
14
15
|
},
|
15
|
-
"author": "Kevin
|
16
|
+
"author": "Kevin Newton",
|
16
17
|
"license": "MIT",
|
17
18
|
"bugs": {
|
18
19
|
"url": "https://github.com/prettier/plugin-ruby/issues"
|
19
20
|
},
|
20
21
|
"homepage": "https://github.com/prettier/plugin-ruby#readme",
|
21
22
|
"dependencies": {
|
22
|
-
"prettier": ">=
|
23
|
+
"prettier": ">=2.3.0"
|
23
24
|
},
|
24
25
|
"devDependencies": {
|
26
|
+
"@types/jest": "^27.0.1",
|
27
|
+
"@types/node": "^16.9.1",
|
28
|
+
"@types/prettier": "^2.3.2",
|
29
|
+
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
30
|
+
"@typescript-eslint/parser": "^4.31.2",
|
25
31
|
"eslint": "^7.22.0",
|
26
32
|
"eslint-config-prettier": "^8.0.0",
|
27
|
-
"husky": "^
|
33
|
+
"husky": "^7.0.0",
|
28
34
|
"jest": "^27.0.1",
|
29
|
-
"pretty-quick": "^3.1.0"
|
35
|
+
"pretty-quick": "^3.1.0",
|
36
|
+
"ts-jest": "^27.0.5",
|
37
|
+
"ts-node": "^10.2.1",
|
38
|
+
"typescript": "^4.4.3"
|
30
39
|
},
|
31
40
|
"eslintConfig": {
|
32
41
|
"extends": [
|
33
42
|
"eslint:recommended",
|
43
|
+
"plugin:@typescript-eslint/recommended",
|
34
44
|
"prettier"
|
35
45
|
],
|
36
46
|
"env": {
|
@@ -38,23 +48,21 @@
|
|
38
48
|
"jest": true,
|
39
49
|
"node": true
|
40
50
|
},
|
51
|
+
"parser": "@typescript-eslint/parser",
|
41
52
|
"rules": {
|
42
|
-
"no-unused-vars":
|
43
|
-
|
44
|
-
|
45
|
-
"argsIgnorePattern": "^_",
|
46
|
-
"varsIgnorePattern": "^_"
|
47
|
-
}
|
48
|
-
]
|
53
|
+
"no-unused-vars": "off",
|
54
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
55
|
+
"@typescript-eslint/no-explicit-any": "off"
|
49
56
|
}
|
50
57
|
},
|
51
58
|
"jest": {
|
52
|
-
"globalSetup": "./test/js/globalSetup.
|
53
|
-
"globalTeardown": "./test/js/globalTeardown.
|
59
|
+
"globalSetup": "./test/js/globalSetup.ts",
|
60
|
+
"globalTeardown": "./test/js/globalTeardown.ts",
|
61
|
+
"preset": "ts-jest",
|
54
62
|
"setupFilesAfterEnv": [
|
55
|
-
"./test/js/setupTests.
|
63
|
+
"./test/js/setupTests.ts"
|
56
64
|
],
|
57
|
-
"testRegex": ".test.
|
65
|
+
"testRegex": ".test.ts$"
|
58
66
|
},
|
59
67
|
"husky": {
|
60
68
|
"hooks": {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prettier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Kevin
|
7
|
+
- Kevin Newton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -23,6 +23,75 @@ files:
|
|
23
23
|
- LICENSE
|
24
24
|
- README.md
|
25
25
|
- bin/console
|
26
|
+
- dist/haml/embed.js
|
27
|
+
- dist/haml/parser.js
|
28
|
+
- dist/haml/parser.rb
|
29
|
+
- dist/haml/printer.js
|
30
|
+
- dist/parser/getInfo.js
|
31
|
+
- dist/parser/netcat.js
|
32
|
+
- dist/parser/parseSync.js
|
33
|
+
- dist/parser/server.rb
|
34
|
+
- dist/plugin.js
|
35
|
+
- dist/prettier.js
|
36
|
+
- dist/rbs/parser.js
|
37
|
+
- dist/rbs/parser.rb
|
38
|
+
- dist/rbs/printer.js
|
39
|
+
- dist/ruby/embed.js
|
40
|
+
- dist/ruby/nodes.js
|
41
|
+
- dist/ruby/nodes/alias.js
|
42
|
+
- dist/ruby/nodes/aref.js
|
43
|
+
- dist/ruby/nodes/args.js
|
44
|
+
- dist/ruby/nodes/arrays.js
|
45
|
+
- dist/ruby/nodes/assign.js
|
46
|
+
- dist/ruby/nodes/blocks.js
|
47
|
+
- dist/ruby/nodes/calls.js
|
48
|
+
- dist/ruby/nodes/case.js
|
49
|
+
- dist/ruby/nodes/class.js
|
50
|
+
- dist/ruby/nodes/commands.js
|
51
|
+
- dist/ruby/nodes/conditionals.js
|
52
|
+
- dist/ruby/nodes/constants.js
|
53
|
+
- dist/ruby/nodes/flow.js
|
54
|
+
- dist/ruby/nodes/hashes.js
|
55
|
+
- dist/ruby/nodes/heredocs.js
|
56
|
+
- dist/ruby/nodes/hooks.js
|
57
|
+
- dist/ruby/nodes/ints.js
|
58
|
+
- dist/ruby/nodes/lambdas.js
|
59
|
+
- dist/ruby/nodes/loops.js
|
60
|
+
- dist/ruby/nodes/massign.js
|
61
|
+
- dist/ruby/nodes/methods.js
|
62
|
+
- dist/ruby/nodes/operators.js
|
63
|
+
- dist/ruby/nodes/params.js
|
64
|
+
- dist/ruby/nodes/patterns.js
|
65
|
+
- dist/ruby/nodes/regexp.js
|
66
|
+
- dist/ruby/nodes/rescue.js
|
67
|
+
- dist/ruby/nodes/return.js
|
68
|
+
- dist/ruby/nodes/statements.js
|
69
|
+
- dist/ruby/nodes/strings.js
|
70
|
+
- dist/ruby/nodes/super.js
|
71
|
+
- dist/ruby/nodes/undef.js
|
72
|
+
- dist/ruby/parser.js
|
73
|
+
- dist/ruby/parser.rb
|
74
|
+
- dist/ruby/printer.js
|
75
|
+
- dist/ruby/toProc.js
|
76
|
+
- dist/types.js
|
77
|
+
- dist/types/haml.js
|
78
|
+
- dist/types/plugin.js
|
79
|
+
- dist/types/rbs.js
|
80
|
+
- dist/types/ruby.js
|
81
|
+
- dist/types/utils.js
|
82
|
+
- dist/utils.js
|
83
|
+
- dist/utils/containsAssignment.js
|
84
|
+
- dist/utils/getTrailingComma.js
|
85
|
+
- dist/utils/hasAncestor.js
|
86
|
+
- dist/utils/inlineEnsureParens.js
|
87
|
+
- dist/utils/isEmptyBodyStmt.js
|
88
|
+
- dist/utils/isEmptyStmts.js
|
89
|
+
- dist/utils/literal.js
|
90
|
+
- dist/utils/literallineWithoutBreakParent.js
|
91
|
+
- dist/utils/makeCall.js
|
92
|
+
- dist/utils/noIndent.js
|
93
|
+
- dist/utils/printEmptyCollection.js
|
94
|
+
- dist/utils/skipAssignIndent.js
|
26
95
|
- exe/rbprettier
|
27
96
|
- lib/prettier.rb
|
28
97
|
- lib/prettier/rake/task.rb
|
@@ -45,68 +114,6 @@ files:
|
|
45
114
|
- node_modules/prettier/third-party.js
|
46
115
|
- package.json
|
47
116
|
- rubocop.yml
|
48
|
-
- src/haml/embed.js
|
49
|
-
- src/haml/parser.js
|
50
|
-
- src/haml/parser.rb
|
51
|
-
- src/haml/printer.js
|
52
|
-
- src/parser/netcat.js
|
53
|
-
- src/parser/parseSync.js
|
54
|
-
- src/parser/server.rb
|
55
|
-
- src/plugin.js
|
56
|
-
- src/prettier.js
|
57
|
-
- src/rbs/parser.js
|
58
|
-
- src/rbs/parser.rb
|
59
|
-
- src/rbs/printer.js
|
60
|
-
- src/ruby/embed.js
|
61
|
-
- src/ruby/nodes.js
|
62
|
-
- src/ruby/nodes/alias.js
|
63
|
-
- src/ruby/nodes/aref.js
|
64
|
-
- src/ruby/nodes/args.js
|
65
|
-
- src/ruby/nodes/arrays.js
|
66
|
-
- src/ruby/nodes/assign.js
|
67
|
-
- src/ruby/nodes/blocks.js
|
68
|
-
- src/ruby/nodes/calls.js
|
69
|
-
- src/ruby/nodes/case.js
|
70
|
-
- src/ruby/nodes/class.js
|
71
|
-
- src/ruby/nodes/commands.js
|
72
|
-
- src/ruby/nodes/conditionals.js
|
73
|
-
- src/ruby/nodes/constants.js
|
74
|
-
- src/ruby/nodes/flow.js
|
75
|
-
- src/ruby/nodes/hashes.js
|
76
|
-
- src/ruby/nodes/heredocs.js
|
77
|
-
- src/ruby/nodes/hooks.js
|
78
|
-
- src/ruby/nodes/ints.js
|
79
|
-
- src/ruby/nodes/lambdas.js
|
80
|
-
- src/ruby/nodes/loops.js
|
81
|
-
- src/ruby/nodes/massign.js
|
82
|
-
- src/ruby/nodes/methods.js
|
83
|
-
- src/ruby/nodes/operators.js
|
84
|
-
- src/ruby/nodes/params.js
|
85
|
-
- src/ruby/nodes/patterns.js
|
86
|
-
- src/ruby/nodes/regexp.js
|
87
|
-
- src/ruby/nodes/rescue.js
|
88
|
-
- src/ruby/nodes/return.js
|
89
|
-
- src/ruby/nodes/statements.js
|
90
|
-
- src/ruby/nodes/strings.js
|
91
|
-
- src/ruby/nodes/super.js
|
92
|
-
- src/ruby/nodes/undef.js
|
93
|
-
- src/ruby/parser.js
|
94
|
-
- src/ruby/parser.rb
|
95
|
-
- src/ruby/printer.js
|
96
|
-
- src/ruby/toProc.js
|
97
|
-
- src/utils.js
|
98
|
-
- src/utils/containsAssignment.js
|
99
|
-
- src/utils/getTrailingComma.js
|
100
|
-
- src/utils/hasAncestor.js
|
101
|
-
- src/utils/inlineEnsureParens.js
|
102
|
-
- src/utils/isEmptyBodyStmt.js
|
103
|
-
- src/utils/isEmptyStmts.js
|
104
|
-
- src/utils/literal.js
|
105
|
-
- src/utils/literallineWithoutBreakParent.js
|
106
|
-
- src/utils/makeCall.js
|
107
|
-
- src/utils/noIndent.js
|
108
|
-
- src/utils/printEmptyCollection.js
|
109
|
-
- src/utils/skipAssignIndent.js
|
110
117
|
homepage: https://github.com/prettier/plugin-ruby#readme
|
111
118
|
licenses:
|
112
119
|
- MIT
|
@@ -122,9 +129,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
129
|
version: '0'
|
123
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
131
|
requirements:
|
125
|
-
- - "
|
132
|
+
- - ">"
|
126
133
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
134
|
+
version: 1.3.1
|
128
135
|
requirements: []
|
129
136
|
rubygems_version: 3.2.3
|
130
137
|
signing_key:
|
data/src/haml/embed.js
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
const {
|
2
|
-
concat,
|
3
|
-
hardline,
|
4
|
-
indent,
|
5
|
-
literalline,
|
6
|
-
markAsRoot,
|
7
|
-
mapDoc,
|
8
|
-
stripTrailingHardline
|
9
|
-
} = require("../prettier");
|
10
|
-
|
11
|
-
// Get the name of the parser that is represented by the given element node,
|
12
|
-
// return null if a matching parser cannot be found
|
13
|
-
function getParser(name, opts) {
|
14
|
-
let parser = name;
|
15
|
-
|
16
|
-
// We don't want to deal with some weird recursive parser situation, so we
|
17
|
-
// need to explicitly call out the HAML parser here and just return null
|
18
|
-
if (parser === "haml") {
|
19
|
-
return null;
|
20
|
-
}
|
21
|
-
|
22
|
-
// In HAML the name of the JS filter is :javascript, whereas in prettier the
|
23
|
-
// name of the JS parser is babel. Here we explicitly handle that conversion.
|
24
|
-
if (parser === "javascript") {
|
25
|
-
parser = "babel";
|
26
|
-
}
|
27
|
-
|
28
|
-
// If there is a plugin that has a parser that matches the name of this
|
29
|
-
// element, then we're going to assume that's correct for embedding and go
|
30
|
-
// ahead and switch to that parser
|
31
|
-
if (
|
32
|
-
opts.plugins.some(
|
33
|
-
(plugin) =>
|
34
|
-
plugin.parsers &&
|
35
|
-
Object.prototype.hasOwnProperty.call(plugin.parsers, parser)
|
36
|
-
)
|
37
|
-
) {
|
38
|
-
return parser;
|
39
|
-
}
|
40
|
-
|
41
|
-
return null;
|
42
|
-
}
|
43
|
-
|
44
|
-
// This function is in here because it handles embedded parser values. I don't
|
45
|
-
// have a test that exercises it because I'm not sure for which parser it is
|
46
|
-
// necessary, but since it's in prettier core I'm keeping it here.
|
47
|
-
/* istanbul ignore next */
|
48
|
-
function replaceNewlines(doc) {
|
49
|
-
return mapDoc(doc, (currentDoc) =>
|
50
|
-
typeof currentDoc === "string" && currentDoc.includes("\n")
|
51
|
-
? concat(
|
52
|
-
currentDoc
|
53
|
-
.split(/(\n)/g)
|
54
|
-
.map((v, i) => (i % 2 === 0 ? v : literalline))
|
55
|
-
)
|
56
|
-
: currentDoc
|
57
|
-
);
|
58
|
-
}
|
59
|
-
|
60
|
-
function embed(path, _print, textToDoc, opts) {
|
61
|
-
const node = path.getValue();
|
62
|
-
if (node.type !== "filter") {
|
63
|
-
return null;
|
64
|
-
}
|
65
|
-
|
66
|
-
const parser = getParser(node.value.name, opts);
|
67
|
-
if (!parser) {
|
68
|
-
return null;
|
69
|
-
}
|
70
|
-
|
71
|
-
return markAsRoot(
|
72
|
-
concat([
|
73
|
-
":",
|
74
|
-
node.value.name,
|
75
|
-
indent(
|
76
|
-
concat([
|
77
|
-
hardline,
|
78
|
-
replaceNewlines(
|
79
|
-
stripTrailingHardline(textToDoc(node.value.text, { parser }))
|
80
|
-
)
|
81
|
-
])
|
82
|
-
)
|
83
|
-
])
|
84
|
-
);
|
85
|
-
}
|
86
|
-
|
87
|
-
module.exports = embed;
|