Closed fisker closed 3 years ago
run with pr 9672
run with pr 9672
Diff by prettier/prettier@002dc6c45fd3f57d29e3f051e4a6362d32a8842f
babel/babel@f4edf62f6beeab8ae9f2b7f0b82f1b3b12a581af
vuejs/eslint-plugin-vue@80b8983118cc08cf473642c05413bcb930c93613
excalidraw/excalidraw@7491fcc3f397f731498c0f279e48b25428a10003
prettier/prettier@d5cfb5b856911a4b0ca58808b9b5789a276b7c8c
typescript-eslint/typescript-eslint@5de66142f2391b000aa939b86d4756ee621553ad
Submodule repos/babel contains modified content
diff --git a/repos/babel/packages/babel-core/test/api.js b/repos/babel/packages/babel-core/test/api.js
index bf714bc6e..c2e25f6fc 100644
--- a/repos/babel/packages/babel-core/test/api.js
+++ b/repos/babel/packages/babel-core/test/api.js
@@ -167,16 +167,17 @@ describe("api", function () {
babelrc: false,
};
Object.freeze(options);
transformFile(__dirname + "/fixtures/api/file.js", options, function (
err,
res,
) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
});
transformFile(
__dirname + "/fixtures/api/file.js",
options,
function (err, res) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
},
); });
it("transformFileSync", function () { diff --git a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js index 95ca9b119..baeca41a9 100644 --- a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js +++ b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js @@ -4,7 +4,7 @@
const proposalPlugins = new Set([ "proposal-class-properties",
"proposal-private-methods"
"proposal-private-methods", ]);
// use intermediary object to enforce alphabetical key order
diff --git a/repos/babel/packages/babel-traverse/src/path/ancestry.js b/repos/babel/packages/babel-traverse/src/path/ancestry.js
index 758def8e5..73ab074b9 100644
--- a/repos/babel/packages/babel-traverse/src/path/ancestry.js
+++ b/repos/babel/packages/babel-traverse/src/path/ancestry.js
@@ -78,43 +78,42 @@ export function getStatementParent(): NodePath {
export function getEarliestCommonAncestorFrom(
paths: Array
return this.getDeepestCommonAncestorFrom(paths, function (
deepest,
i,
ancestries,
) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
return this.getDeepestCommonAncestorFrom(
paths,
function (deepest, i, ancestries) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// first path
if (!earliest) {
earliest = path;
continue;
}
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
// first path
if (!earliest) { earliest = path; continue; }
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
earliest = path;
continue;
}
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
} }
}
return earliest;
});
return earliest;
},
); }
/** Submodule repos/typescript-eslint contains modified content diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 05c35c7a..7b6bf6d3 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -1570,9 +1570,9 @@ export default createRule<Options, MessageIds>({
ignoreNode
on the node sometime after exiting it and before validating offsets.
*/const offsetListeners = Object.keys(baseOffsetListeners).reduce<
TSESLint.RuleListener
(
const offsetListeners = Object.keys(
baseOffsetListeners,
).reduce
Program:exit
listener. This is necessary because a node might
@@ -1590,9 +1590,9 @@ export default createRule<Options, MessageIds>({const listener = baseOffsetListeners[key] as TSESLint.RuleFunction<
TSESTree.Node
;
const listener = baseOffsetListeners[
key
] as TSESLint.RuleFunction
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }
-const PredefinedFormatToCheckFunction: Readonly<Record<
;
const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction
/*
The following nodes are handled by the member-delimiter-style rule
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
index 672f50dc..f76bf47e 100644
--- a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
+++ b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
@@ -16,9 +16,9 @@ const {
isObjectNotArray,
getParserServices,
} = ESLintUtils;
-type InferMessageIdsTypeFromRule
export { diff --git a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts index c57dfc98..0b3c3943 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -19,10 +19,9 @@ const parserOptions = { project: './tsconfig.json', };
-const formatTestNames: Readonly<Record<
TMessageIds extends string
+> = ReportDescriptorBase
interface ReportDescriptorBase
;
;
;
;
;
;
;
run with pr 9672
run with pr 9672
run with pr 9672
Diff by prettier/prettier@002dc6c45fd3f57d29e3f051e4a6362d32a8842f
babel/babel@f4edf62f6beeab8ae9f2b7f0b82f1b3b12a581af
vuejs/eslint-plugin-vue@80b8983118cc08cf473642c05413bcb930c93613
excalidraw/excalidraw@7491fcc3f397f731498c0f279e48b25428a10003
prettier/prettier@d5cfb5b856911a4b0ca58808b9b5789a276b7c8c
typescript-eslint/typescript-eslint@5de66142f2391b000aa939b86d4756ee621553ad
Submodule repos/babel contains modified content
diff --git a/repos/babel/packages/babel-core/test/api.js b/repos/babel/packages/babel-core/test/api.js
index bf714bc6e..c2e25f6fc 100644
--- a/repos/babel/packages/babel-core/test/api.js
+++ b/repos/babel/packages/babel-core/test/api.js
@@ -167,16 +167,17 @@ describe("api", function () {
babelrc: false,
};
Object.freeze(options);
transformFile(__dirname + "/fixtures/api/file.js", options, function (
err,
res,
) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
});
transformFile(
__dirname + "/fixtures/api/file.js",
options,
function (err, res) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
},
); });
it("transformFileSync", function () { diff --git a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js index 95ca9b119..baeca41a9 100644 --- a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js +++ b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js @@ -4,7 +4,7 @@
const proposalPlugins = new Set([ "proposal-class-properties",
"proposal-private-methods"
"proposal-private-methods", ]);
// use intermediary object to enforce alphabetical key order
diff --git a/repos/babel/packages/babel-traverse/src/path/ancestry.js b/repos/babel/packages/babel-traverse/src/path/ancestry.js
index 758def8e5..73ab074b9 100644
--- a/repos/babel/packages/babel-traverse/src/path/ancestry.js
+++ b/repos/babel/packages/babel-traverse/src/path/ancestry.js
@@ -78,43 +78,42 @@ export function getStatementParent(): NodePath {
export function getEarliestCommonAncestorFrom(
paths: Array
return this.getDeepestCommonAncestorFrom(paths, function (
deepest,
i,
ancestries,
) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
return this.getDeepestCommonAncestorFrom(
paths,
function (deepest, i, ancestries) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// first path
if (!earliest) {
earliest = path;
continue;
}
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
// first path
if (!earliest) { earliest = path; continue; }
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
earliest = path;
continue;
}
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
} }
}
return earliest;
});
return earliest;
},
); }
/** Submodule repos/typescript-eslint contains modified content diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 05c35c7a..7b6bf6d3 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -1570,9 +1570,9 @@ export default createRule<Options, MessageIds>({
ignoreNode
on the node sometime after exiting it and before validating offsets.
*/const offsetListeners = Object.keys(baseOffsetListeners).reduce<
TSESLint.RuleListener
(
const offsetListeners = Object.keys(
baseOffsetListeners,
).reduce
Program:exit
listener. This is necessary because a node might
@@ -1590,9 +1590,9 @@ export default createRule<Options, MessageIds>({const listener = baseOffsetListeners[key] as TSESLint.RuleFunction<
TSESTree.Node
;
const listener = baseOffsetListeners[
key
] as TSESLint.RuleFunction
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }
-const PredefinedFormatToCheckFunction: Readonly<Record<
;
const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction
/*
The following nodes are handled by the member-delimiter-style rule
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
index 672f50dc..f76bf47e 100644
--- a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
+++ b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
@@ -16,9 +16,9 @@ const {
isObjectNotArray,
getParserServices,
} = ESLintUtils;
-type InferMessageIdsTypeFromRule
export { diff --git a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts index c57dfc98..0b3c3943 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -19,10 +19,9 @@ const parserOptions = { project: './tsconfig.json', };
-const formatTestNames: Readonly<Record<
TMessageIds extends string
+> = ReportDescriptorBase
interface ReportDescriptorBase
;
;
;
;
;
;
;
run with pr 9672
Diff by Prettier PR 9672
babel/babel@f4edf62f6beeab8ae9f2b7f0b82f1b3b12a581af
vuejs/eslint-plugin-vue@80b8983118cc08cf473642c05413bcb930c93613
excalidraw/excalidraw@7491fcc3f397f731498c0f279e48b25428a10003
prettier/prettier@d5cfb5b856911a4b0ca58808b9b5789a276b7c8c
typescript-eslint/typescript-eslint@5de66142f2391b000aa939b86d4756ee621553ad
Submodule repos/babel contains modified content
diff --git a/repos/babel/packages/babel-core/test/api.js b/repos/babel/packages/babel-core/test/api.js
index bf714bc6e..c2e25f6fc 100644
--- a/repos/babel/packages/babel-core/test/api.js
+++ b/repos/babel/packages/babel-core/test/api.js
@@ -167,16 +167,17 @@ describe("api", function () {
babelrc: false,
};
Object.freeze(options);
transformFile(__dirname + "/fixtures/api/file.js", options, function (
err,
res,
) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
});
transformFile(
__dirname + "/fixtures/api/file.js",
options,
function (err, res) {
if (err) return done(err);
expect(res.code).toBe("foo();");
// keep user options untouched
expect(options).toEqual({ babelrc: false });
done();
},
); });
it("transformFileSync", function () { diff --git a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js index 95ca9b119..baeca41a9 100644 --- a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js +++ b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js @@ -4,7 +4,7 @@
const proposalPlugins = new Set([ "proposal-class-properties",
"proposal-private-methods"
"proposal-private-methods", ]);
// use intermediary object to enforce alphabetical key order
diff --git a/repos/babel/packages/babel-traverse/src/path/ancestry.js b/repos/babel/packages/babel-traverse/src/path/ancestry.js
index 758def8e5..73ab074b9 100644
--- a/repos/babel/packages/babel-traverse/src/path/ancestry.js
+++ b/repos/babel/packages/babel-traverse/src/path/ancestry.js
@@ -78,43 +78,42 @@ export function getStatementParent(): NodePath {
export function getEarliestCommonAncestorFrom(
paths: Array
return this.getDeepestCommonAncestorFrom(paths, function (
deepest,
i,
ancestries,
) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
return this.getDeepestCommonAncestorFrom(
paths,
function (deepest, i, ancestries) {
let earliest;
const keys = t.VISITOR_KEYS[deepest.type];
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// first path
if (!earliest) {
earliest = path;
continue;
}
for (const ancestry of (ancestries: Array)) {
const path = ancestry[i + 1];
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
// first path
if (!earliest) { earliest = path; continue; }
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
// handle containers
if (path.listKey && earliest.listKey === path.listKey) {
// we're in the same container so check if we're earlier
if (path.key < earliest.key) {
earliest = path;
continue;
}
}
// handle keys
const earliestKeyIndex = keys.indexOf(earliest.parentKey);
const currentKeyIndex = keys.indexOf(path.parentKey);
if (earliestKeyIndex > currentKeyIndex) {
// key appears before so it's earlier
earliest = path;
} }
}
return earliest;
});
return earliest;
},
); }
/** Submodule repos/typescript-eslint contains modified content diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts index 05c35c7a..7b6bf6d3 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/indent-new-do-not-use/index.ts @@ -1570,9 +1570,9 @@ export default createRule<Options, MessageIds>({
ignoreNode
on the node sometime after exiting it and before validating offsets.
*/const offsetListeners = Object.keys(baseOffsetListeners).reduce<
TSESLint.RuleListener
(
const offsetListeners = Object.keys(
baseOffsetListeners,
).reduce
Program:exit
listener. This is necessary because a node might
@@ -1590,9 +1590,9 @@ export default createRule<Options, MessageIds>({const listener = baseOffsetListeners[key] as TSESLint.RuleFunction<
TSESTree.Node
;
const listener = baseOffsetListeners[
key
] as TSESLint.RuleFunction
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts index 295e8209..4a9378d7 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/naming-convention.ts @@ -1237,10 +1237,9 @@ function validateUnderscores(name: string): boolean { return !wasUnderscore; }
-const PredefinedFormatToCheckFunction: Readonly<Record<
;
const checkForSemicolon = rules.ExpressionStatement as TSESLint.RuleFunction
/*
The following nodes are handled by the member-delimiter-style rule
diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
index 672f50dc..f76bf47e 100644
--- a/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
+++ b/repos/typescript-eslint/packages/eslint-plugin/src/util/index.ts
@@ -16,9 +16,9 @@ const {
isObjectNotArray,
getParserServices,
} = ESLintUtils;
-type InferMessageIdsTypeFromRule
export { diff --git a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts index c57dfc98..0b3c3943 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -19,10 +19,9 @@ const parserOptions = { project: './tsconfig.json', };
-const formatTestNames: Readonly<Record<
TMessageIds extends string
+> = ReportDescriptorBase
interface ReportDescriptorBase
;
;
;
;
;
;
;
run with pr 8300
Diff by Prettier PR 8300
Submodule repos/babel contains modified content
diff --git a/repos/babel/eslint/babel-eslint-plugin/src/rules/new-cap.js b/repos/babel/eslint/babel-eslint-plugin/src/rules/new-cap.js
index 1fddf1a43..50d933f01 100644
--- a/repos/babel/eslint/babel-eslint-plugin/src/rules/new-cap.js
+++ b/repos/babel/eslint/babel-eslint-plugin/src/rules/new-cap.js
@@ -1,7 +1,9 @@
import ruleComposer from "eslint-rule-composer";
import eslint from "eslint";
-const rule = new eslint.Linter().getRules().get("new-cap"); +const rule = new eslint.Linter()
.get("new-cap");
/**
-const noInvalidThisRule = new eslint.Linter().getRules().get("no-invalid-this"); +const noInvalidThisRule = new eslint.Linter()
.get("no-invalid-this");
export default ruleComposer.filterReports(noInvalidThisRule, problem => { let inClassMember = false; diff --git a/repos/babel/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js b/repos/babel/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js index 455153474..9f9860a34 100644 --- a/repos/babel/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js +++ b/repos/babel/eslint/babel-eslint-plugin/src/rules/no-unused-expressions.js @@ -1,7 +1,9 @@ import ruleComposer from "eslint-rule-composer"; import eslint from "eslint";
-const rule = new eslint.Linter().getRules().get("no-unused-expressions"); +const rule = new eslint.Linter()
.get("no-unused-expressions");
/**
-const rule = new eslint.Linter().getRules().get("object-curly-spacing"); +const rule = new eslint.Linter()
.get("object-curly-spacing");
export default ruleComposer.filterReports(rule, problem => { const node = problem.node; diff --git a/repos/babel/eslint/babel-eslint-plugin/src/rules/semi.js b/repos/babel/eslint/babel-eslint-plugin/src/rules/semi.js index 07e41f917..a90236fca 100644 --- a/repos/babel/eslint/babel-eslint-plugin/src/rules/semi.js +++ b/repos/babel/eslint/babel-eslint-plugin/src/rules/semi.js @@ -3,7 +3,9 @@ import eslint from "eslint";
const OPT_OUT_PATTERN = /^[-[(/+]/; // One of [(/+-
-const rule = new eslint.Linter().getRules().get("semi"); +const rule = new eslint.Linter()
.get("semi");
function isSemicolon(token) {
return token.type === "Punctuator" && token.value === ";";
diff --git a/repos/babel/packages/babel-cli/src/babel/util.js b/repos/babel/packages/babel-cli/src/babel/util.js
index a147d5a79..887de1f5b 100644
--- a/repos/babel/packages/babel-cli/src/babel/util.js
+++ b/repos/babel/packages/babel-cli/src/babel/util.js
@@ -16,15 +16,19 @@ export function readdir(
includeDotfiles: boolean,
filter?: ReaddirFilter,
): Array
); }
export function readdirForCompilable(
@@ -32,9 +36,13 @@ export function readdirForCompilable(
includeDotfiles: boolean,
altExts?: Array
); }
/** diff --git a/repos/babel/packages/babel-compat-data/scripts/utils-build-data.js b/repos/babel/packages/babel-compat-data/scripts/utils-build-data.js index e8a21f4f2..4a82857d6 100644 --- a/repos/babel/packages/babel-compat-data/scripts/utils-build-data.js +++ b/repos/babel/packages/babel-compat-data/scripts/utils-build-data.js @@ -35,17 +35,22 @@ exports.environments = [ "samsung", ];
-const compatibilityTests = flatMap(compatSources, data =>
flatMap(data.tests, test => {
if (!test.subtests) return test;
return test.subtests.map(subtest =>
Object.assign({}, subtest, {
name: test.name + " / " + subtest.name,
group: test.name,
})
);
}) +const compatibilityTests = flatMap(
compatSources,
data =>
flatMap(
data.tests,
test => {
if (!test.subtests) return test;
return test.subtests.map(subtest =>
Object.assign({}, subtest, {
name: test.name + " / " + subtest.name,
group: test.name,
})
);
}
) );
exports.getLowestImplementedVersion = ( @@ -85,23 +90,26 @@ exports.getLowestImplementedVersion = ( };
exports.generateData = (environments, features) => {
return mapValues(features, options => {
if (!options.features) {
options = {
features: [options],
};
return mapValues(
features,
options => {
if (!options.features) {
options = {
features: [options],
};
}
const plugin = {};
environments.forEach(env => {
const version = exports.getLowestImplementedVersion(options, env);
if (version) plugin[env] = version;
});
addElectronSupportFromChromium(plugin);
return plugin; }
const plugin = {};
environments.forEach(env => {
const version = exports.getLowestImplementedVersion(options, env);
if (version) plugin[env] = version;
});
addElectronSupportFromChromium(plugin);
return plugin;
});
); };
exports.writeFile = function (data, dataPath, name) { diff --git a/repos/babel/packages/babel-core/src/config/caching.js b/repos/babel/packages/babel-core/src/config/caching.js index 050c59d85..d60bc3874 100644 --- a/repos/babel/packages/babel-core/src/config/caching.js +++ b/repos/babel/packages/babel-core/src/config/caching.js @@ -128,9 +128,12 @@ function makeCachedFunction<ArgT, ResultT, SideChannel, Cache: >( // Flow refines handlerResult to Generator<any, any, any> const gen = (handlerResult: Generator<, ResultT, *>);
value = yield* onFirstPause(gen, () => {
finishLock = setupAsyncLocks(cache, futureCache, arg);
});
value = yield* onFirstPause(
gen,
() => {
finishLock = setupAsyncLocks(cache, futureCache, arg);
},
); } else { // $FlowIgnore doesn't refine handlerResult to ResultT value = (handlerResult: ResultT); diff --git a/repos/babel/packages/babel-core/src/config/full.js b/repos/babel/packages/babel-core/src/config/full.js index 75fbe293c..9d8ac3fb9 100644 --- a/repos/babel/packages/babel-core/src/config/full.js +++ b/repos/babel/packages/babel-core/src/config/full.js @@ -161,29 +161,32 @@ export default gensync<[any], ResolvedConfig | null>(function* loadFullConfig( const opts: Object = optionDefaults; mergeOptions(opts, options);
yield enhanceError(context, function loadPluginDescriptors() {
pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors);
for (const descs of pluginDescriptorsByPass) {
const pass = [];
passes.push(pass);
for (let i = 0; i < descs.length; i++) {
const descriptor: UnloadedDescriptor = descs[i];
if (descriptor.options !== false) {
try {
pass.push(yield* loadPluginDescriptor(descriptor, context));
} catch (e) {
if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
// print special message for plugins: ["@babel/foo", { foo: "option" }]
checkNoUnwrappedItemOptionPairs(descs, i, "plugin", e);
yield* enhanceError(
context,
function* loadPluginDescriptors() {
pluginDescriptorsByPass[0].unshift(...initialPluginsDescriptors);
for (const descs of pluginDescriptorsByPass) {
const pass = [];
passes.push(pass);
for (let i = 0; i < descs.length; i++) {
const descriptor: UnloadedDescriptor = descs[i];
if (descriptor.options !== false) {
try {
pass.push(yield* loadPluginDescriptor(descriptor, context));
} catch (e) {
if (e.code === "BABEL_UNKNOWN_PLUGIN_PROPERTY") {
// print special message for plugins: ["@babel/foo", { foo: "option" }]
checkNoUnwrappedItemOptionPairs(descs, i, "plugin", e);
}
throw e; }
throw e; } } }
}
})();
},
)();
opts.plugins = passes[0]; opts.presets = passes @@ -307,10 +310,13 @@ const instantiatePlugin = makeWeakCache(function* ( dirname, };
const inherits = yield* forwardAsync(loadPluginDescriptor, run => {
// If the inherited plugin changes, reinstantiate this plugin.
return cache.invalidate(data => run(inheritsDescriptor, data));
});
const inherits = yield* forwardAsync(
loadPluginDescriptor,
run => {
// If the inherited plugin changes, reinstantiate this plugin.
return cache.invalidate(data => run(inheritsDescriptor, data));
},
);
plugin.pre = chain(inherits.pre, plugin.pre); plugin.post = chain(inherits.post, plugin.post); diff --git a/repos/babel/packages/babel-core/src/transformation/block-hoist-plugin.js b/repos/babel/packages/babel-core/src/transformation/block-hoist-plugin.js index 477d2d5c3..5901aaf22 100644 --- a/repos/babel/packages/babel-core/src/transformation/block-hoist-plugin.js +++ b/repos/babel/packages/babel-core/src/transformation/block-hoist-plugin.js @@ -51,14 +51,17 @@ const blockHoistPlugin = { } if (!hasChange) return;
node.body = sortBy(node.body, function (bodyNode) {
let priority = bodyNode?._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;
node.body = sortBy(
node.body,
function (bodyNode) {
let priority = bodyNode?._blockHoist;
if (priority == null) priority = 1;
if (priority === true) priority = 2;
// Higher priorities should move toward the top.
return -1 * priority;
});
// Higher priorities should move toward the top.
return -1 * priority;
},
); }, }, }, diff --git a/repos/babel/packages/babel-core/src/transformation/file/merge-map.js b/repos/babel/packages/babel-core/src/transformation/file/merge-map.js index 911867d96..02825f678 100644 --- a/repos/babel/packages/babel-core/src/transformation/file/merge-map.js +++ b/repos/babel/packages/babel-core/src/transformation/file/merge-map.js @@ -123,15 +123,18 @@ function filterApplicableOriginalRanges( ): OriginalMappings { // The mapping array is sorted by original location, so we can // binary-search it for the overlapping ranges.
return filterSortedArray(mappings, ({ original: outOriginal }) => {
if (line > outOriginal.line) return -1;
if (line < outOriginal.line) return 1;
return filterSortedArray(
mappings,
({ original: outOriginal }) => {
if (line > outOriginal.line) return -1;
if (line < outOriginal.line) return 1;
if (columnStart >= outOriginal.columnEnd) return -1;
if (columnEnd <= outOriginal.columnStart) return 1;
if (columnStart >= outOriginal.columnEnd) return -1;
if (columnEnd <= outOriginal.columnStart) return 1;
return 0;
});
return 0;
},
); }
function eachInputGeneratedRange( diff --git a/repos/babel/packages/babel-core/test/api.js b/repos/babel/packages/babel-core/test/api.js index bf714bc6e..cc2bdd77c 100644 --- a/repos/babel/packages/babel-core/test/api.js +++ b/repos/babel/packages/babel-core/test/api.js @@ -454,24 +454,36 @@ describe("api", function () {
// Writes value properly. expect(
doTransform("", file => {
file.shebang = "env node";
}),
doTransform(
"",
file => {
file.shebang = "env node";
},
),
).toBe(#!env node
);
expect(
doTransform("#!env node", file => {
file.shebang = "env node2";
}),
doTransform(
"#!env node",
file => {
file.shebang = "env node2";
},
),
).toBe(#!env node2
);
expect(
doTransform("", file => {
file.shebang = "";
}),
doTransform(
"",
file => {
file.shebang = "";
},
), ).toBe(``); expect(
doTransform("#!env node", file => {
file.shebang = "";
}),
doTransform(
"#!env node",
file => {
file.shebang = "";
},
), ).toBe(``);
// Reads value properly. @@ -484,14 +496,17 @@ describe("api", function () {
// Reads and writes properly. expect(
doTransform("#!env node", file => {
expect(file.shebang).toBe("env node");
doTransform(
"#!env node",
file => {
expect(file.shebang).toBe("env node");
file.shebang = "env node2";
expect(file.shebang).toBe("env node2");
file.shebang = "env node2";
expect(file.shebang).toBe("env node2");
file.shebang = "env node3";
}),
file.shebang = "env node3";
},
),
).toBe(#!env node3
);
});
diff --git a/repos/babel/packages/babel-core/test/path.js b/repos/babel/packages/babel-core/test/path.js index 2edb48921..d151b88c8 100644 --- a/repos/babel/packages/babel-core/test/path.js +++ b/repos/babel/packages/babel-core/test/path.js @@ -30,18 +30,20 @@ describe("traversal path", function () { new Plugin({ visitor: { ArrowFunctionExpression: function (path) {
@@ -1888,8 +1889,9 @@ export default (superClass: Class
node.test = expr;
node.consequent = consequent;
node.alternate = this.forwardNoArrowParamsConversionAt(node, () =>
this.parseMaybeAssign(undefined, undefined, undefined),
node.alternate = this.forwardNoArrowParamsConversionAt(
node,
() => this.parseMaybeAssign(undefined, undefined, undefined), );
return this.finishNode(node, "ConditionalExpression");
@@ -1944,8 +1946,9 @@ export default (superClass: Class
return partition(arrows, node =>
node.params.every(param => this.isAssignable(param, true)),
return partition(
arrows,
node => node.params.every(param => this.isAssignable(param, true)), ); }
diff --git a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js index 95ca9b119..baeca41a9 100644 --- a/repos/babel/packages/babel-preset-env/data/shipped-proposals.js +++ b/repos/babel/packages/babel-preset-env/data/shipped-proposals.js @@ -4,7 +4,7 @@
const proposalPlugins = new Set([ "proposal-class-properties",
"proposal-private-methods"
"proposal-private-methods", ]);
// use intermediary object to enforce alphabetical key order diff --git a/repos/babel/packages/babel-traverse/src/path/conversion.js b/repos/babel/packages/babel-traverse/src/path/conversion.js index 2ca47297c..cc6f0d253 100644 --- a/repos/babel/packages/babel-traverse/src/path/conversion.js +++ b/repos/babel/packages/babel-traverse/src/path/conversion.js @@ -218,8 +218,10 @@ function hoistFunctionEnvironment(
// Convert all "arguments" references in the arrow to point at the alias. if (argumentsPaths.length > 0) {
const argumentsBinding = getBinding(thisEnvFn, "arguments", () =>
t.identifier("arguments"),
const argumentsBinding = getBinding(
thisEnvFn,
"arguments",
() => t.identifier("arguments"), );
argumentsPaths.forEach(argumentsChild => { @@ -232,8 +234,10 @@ function hoistFunctionEnvironment(
// Convert all "new.target" references in the arrow to point at the alias. if (newTargetPaths.length > 0) {
const newTargetBinding = getBinding(thisEnvFn, "newtarget", () =>
t.metaProperty(t.identifier("new"), t.identifier("target")),
const newTargetBinding = getBinding(
thisEnvFn,
"newtarget",
() => t.metaProperty(t.identifier("new"), t.identifier("target")), );
newTargetPaths.forEach(targetChild => { @@ -440,84 +444,97 @@ function hasSuperClass(thisEnvFn) {
// Create a binding that evaluates to the "this" of the given function. function getThisBinding(thisEnvFn, inConstructor) {
return getBinding(thisEnvFn, "this", thisBinding => {
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
const supers = new WeakSet();
thisEnvFn.traverse({
Function(child) {
if (child.isArrowFunctionExpression()) return;
child.skip();
},
ClassProperty(child) {
child.skip();
},
CallExpression(child) {
if (!child.get("callee").isSuper()) return;
if (supers.has(child.node)) return;
supers.add(child.node);
child.replaceWithMultiple([
child.node,
t.assignmentExpression(
"=",
t.identifier(thisBinding),
t.identifier("this"),
),
]);
},
});
});
return getBinding(
thisEnvFn,
"this",
thisBinding => {
if (!inConstructor || !hasSuperClass(thisEnvFn))
return t.thisExpression();
const supers = new WeakSet();
thisEnvFn.traverse({
Function(child) {
if (child.isArrowFunctionExpression()) return;
child.skip();
},
ClassProperty(child) {
child.skip();
},
CallExpression(child) {
if (!child.get("callee").isSuper()) return;
if (supers.has(child.node)) return;
supers.add(child.node);
child.replaceWithMultiple([
child.node,
t.assignmentExpression(
"=",
t.identifier(thisBinding),
t.identifier("this"),
),
]);
},
});
},
); }
// Create a binding for a function that will call "super()" with arguments passed through. function getSuperBinding(thisEnvFn) {
return getBinding(thisEnvFn, "supercall", () => {
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
return t.arrowFunctionExpression(
[t.restElement(argsBinding)],
t.callExpression(t.super(), [
t.spreadElement(t.identifier(argsBinding.name)),
]),
);
});
return getBinding(
thisEnvFn,
"supercall",
() => {
const argsBinding = thisEnvFn.scope.generateUidIdentifier("args");
return t.arrowFunctionExpression(
[t.restElement(argsBinding)],
t.callExpression(t.super(), [
t.spreadElement(t.identifier(argsBinding.name)),
]),
);
},
); }
// Create a binding for a function that will call "super.foo" or "super[foo]". function getSuperPropBinding(thisEnvFn, isAssignment, propName) { const op = isAssignment ? "set" : "get";
return getBinding(thisEnvFn, superprop_${op}:${propName || ""}
, () => {
const argsList = [];
return getBinding(
thisEnvFn,
superprop_${op}:${propName || ""}
,
() => {
const argsList = [];
let fnBody;
if (propName) {
// () => super.foo
fnBody = t.memberExpression(t.super(), t.identifier(propName));
} else {
const method = thisEnvFn.scope.generateUidIdentifier("prop");
// (method) => super[method]
argsList.unshift(method);
fnBody = t.memberExpression(
t.super(),
t.identifier(method.name),
true / computed /,
);
}
let fnBody;
if (propName) {
// () => super.foo
fnBody = t.memberExpression(t.super(), t.identifier(propName));
} else {
const method = thisEnvFn.scope.generateUidIdentifier("prop");
// (method) => super[method]
argsList.unshift(method);
fnBody = t.memberExpression(
t.super(),
t.identifier(method.name),
true / computed /,
);
}
if (isAssignment) {
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
argsList.push(valueIdent);
if (isAssignment) {
const valueIdent = thisEnvFn.scope.generateUidIdentifier("value");
argsList.push(valueIdent);
fnBody = t.assignmentExpression(
"=",
fnBody,
t.identifier(valueIdent.name),
);
}
fnBody = t.assignmentExpression(
"=",
fnBody,
t.identifier(valueIdent.name),
);
}
return t.arrowFunctionExpression(argsList, fnBody);
});
return t.arrowFunctionExpression(argsList, fnBody);
},
); }
function getBinding(thisEnvFn, key, init) { Submodule repos/eslint-plugin-vue contains modified content diff --git a/repos/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js b/repos/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js index b209376..dd89449 100644 --- a/repos/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js +++ b/repos/eslint-plugin-vue/lib/rules/experimental-script-setup-vars.js @@ -57,9 +57,11 @@ module.exports = {
let eslintScope try {
eslintScope = getESLintModule('eslint-scope', () =>
// @ts-ignore
require('eslint-scope')
eslintScope = getESLintModule(
'eslint-scope',
() =>
// @ts-ignore
require('eslint-scope') ) } catch (_e) { context.report({ @@ -70,9 +72,11 @@ module.exports = { } let espree try {
espree = getESLintModule('espree', () =>
// @ts-ignore
require('espree')
espree = getESLintModule(
'espree',
() =>
// @ts-ignore
require('espree')
)
} catch (_e) {
context.report({
diff --git a/repos/eslint-plugin-vue/lib/rules/no-unused-properties.js b/repos/eslint-plugin-vue/lib/rules/no-unused-properties.js
index 75b56a4..fb1978c 100644
--- a/repos/eslint-plugin-vue/lib/rules/no-unused-properties.js
+++ b/repos/eslint-plugin-vue/lib/rules/no-unused-properties.js
@@ -267,8 +267,9 @@ function extractPatternOrThisProperties(node, context) {
// arg.foo
const name = utils.getStaticPropertyName(parent)
if (name) {
result.usedNames.add(name, () =>
extractPatternOrThisProperties(parent, context)
result.usedNames.add(
name,
() => extractPatternOrThisProperties(parent, context) ) } else { result.unknown = true diff --git a/repos/eslint-plugin-vue/tests/lib/utils/html-comments.js b/repos/eslint-plugin-vue/tests/lib/utils/html-comments.js index 066c73e..6a0297e 100644 --- a/repos/eslint-plugin-vue/tests/lib/utils/html-comments.js +++ b/repos/eslint-plugin-vue/tests/lib/utils/html-comments.js @@ -37,10 +37,12 @@ function tokenize(code, option) { const linter = new Linter() const result = []
linter.defineRule('vue/html-comments-test', (content) =>
htmlComments.defineVisitor(content, option, (commentTokens) => {
result.push(commentTokens)
})
linter.defineRule(
'vue/html-comments-test',
(content) =>
htmlComments.defineVisitor(content, option, (commentTokens) => {
result.push(commentTokens)
})
)
linter.defineParser('vue-eslint-parser', require('vue-eslint-parser'))
linter.verify(
Submodule repos/prettier contains modified content
diff --git a/repos/prettier/scripts/draft-blog-post.js b/repos/prettier/scripts/draft-blog-post.js
index 39f48c59a..df8345d9a 100644
--- a/repos/prettier/scripts/draft-blog-post.js
+++ b/repos/prettier/scripts/draft-blog-post.js
@@ -15,7 +15,9 @@ const version = require("../package.json").version.replace(/-.+/, "");
const postGlob = path.join(blogDir, ????-??-??-${version}.md
);
const postFile = path.join(
blogDir,
${new Date().toISOString().replace(/T.+/, "")}-${version}.md
`${new Date()
.toISOString()
.replace(/T.+/, "")}-${version}.md` );
const categories = [ diff --git a/repos/prettier/scripts/release/steps/update-dependents-count.js b/repos/prettier/scripts/release/steps/update-dependents-count.js index 1167c8182..a4b26e1f8 100644 --- a/repos/prettier/scripts/release/steps/update-dependents-count.js +++ b/repos/prettier/scripts/release/steps/update-dependents-count.js @@ -41,16 +41,18 @@ async function update() { ); }
processFile("website/pages/en/index.js", (content) =>
content
.replace(
/()(.*?)(<\/strong>)/,
$1${formatNumber(dependentsCountNpm)}$3
)
.replace(
/()(.*?)(<\/strong>)/,
$1${formatNumber(dependentsCountGithub)}$3
)
processFile(
"website/pages/en/index.js",
(content) =>
content
.replace(
/()(.*?)(<\/strong>)/,
$1${formatNumber(dependentsCountNpm)}$3
)
.replace(
/()(.*?)(<\/strong>)/,
$1${formatNumber(dependentsCountGithub)}$3
) );
const isUpdated = await logPromise( diff --git a/repos/prettier/scripts/release/steps/update-version.js b/repos/prettier/scripts/release/steps/update-version.js index 081820765..cdf24f1a4 100644 --- a/repos/prettier/scripts/release/steps/update-version.js +++ b/repos/prettier/scripts/release/steps/update-version.js @@ -9,19 +9,25 @@ async function bump({ version }) { await writeJson("package.json", pkg, { spaces: 2 });
// Update github issue templates
processFile(".github/ISSUE_TEMPLATE/formatting.md", (content) =>
content.replace(/^(**Prettier ).?(*\)$/m, $1${version}$2
)
processFile(
".github/ISSUE_TEMPLATE/formatting.md",
(content) =>
content.replace(/^(**Prettier ).?(*\)$/m, $1${version}$2
)
);
processFile(".github/ISSUE_TEMPLATE/integration.md", (content) =>
content.replace(/^(- Prettier Version: ).*?$/m, $1${version}
)
processFile(
".github/ISSUE_TEMPLATE/integration.md",
(content) => content.replace(/^(- Prettier Version: ).*?$/m, $1${version}
)
);
processFile("docs/install.md", (content) =>
content.replace(/^(npx prettier@)\S+/m, $1${version}
)
processFile(
"docs/install.md",
(content) => content.replace(/^(npx prettier@)\S+/m, $1${version}
)
);
// Update unpkg link in docs
processFile("docs/browser.md", (content) =>
content.replace(/(\/\/unpkg.com\/prettier@).*?\//g, $1${version}/
)
processFile(
"docs/browser.md",
(content) =>
content.replace(/(\/\/unpkg.com\/prettier@).*?\//g, $1${version}/
)
);
await execa("yarn", ["update-stable-docs"], { diff --git a/repos/prettier/src/document/doc-utils.js b/repos/prettier/src/document/doc-utils.js index d9fe00900..a4c937eb5 100644 --- a/repos/prettier/src/document/doc-utils.js +++ b/repos/prettier/src/document/doc-utils.js @@ -249,26 +249,31 @@ function normalizeParts(parts) { }
function normalizeDoc(doc) {
return mapDoc(doc, (currentDoc) => {
if (!currentDoc.parts) {
return currentDoc;
return mapDoc(
doc,
(currentDoc) => {
if (!currentDoc.parts) {
return currentDoc;
}
return {
...currentDoc,
parts: normalizeParts(currentDoc.parts),
}; }
return {
...currentDoc,
parts: normalizeParts(currentDoc.parts),
};
});
); }
function replaceNewlinesWithLiterallines(doc) {
return mapDoc(doc, (currentDoc) =>
typeof currentDoc === "string" && currentDoc.includes("\n")
? concat(
currentDoc
.split(/(\n)/g)
.map((v, i) => (i % 2 === 0 ? v : literalline))
)
: currentDoc
return mapDoc(
doc,
(currentDoc) =>
typeof currentDoc === "string" && currentDoc.includes("\n")
? concat(
currentDoc
.split(/(\n)/g)
.map((v, i) => (i % 2 === 0 ? v : literalline))
)
: currentDoc ); }
diff --git a/repos/prettier/src/language-css/index.js b/repos/prettier/src/language-css/index.js index c69c43461..1f881d51d 100644 --- a/repos/prettier/src/language-css/index.js +++ b/repos/prettier/src/language-css/index.js @@ -5,32 +5,44 @@ const printer = require("./printer-postcss"); const options = require("./options");
const languages = [
createLanguage(require("linguist-languages/data/CSS.json"), (data) => ({
since: "1.4.0",
parsers: ["css"],
vscodeLanguageIds: ["css"],
extensions: [
...data.extensions,
// WeiXin Style Sheets
(Weixin Mini Programs)
// https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
".wxss",
],
})),
createLanguage(require("linguist-languages/data/PostCSS.json"), () => ({
since: "1.4.0",
parsers: ["css"],
vscodeLanguageIds: ["postcss"],
})),
createLanguage(require("linguist-languages/data/Less.json"), () => ({
since: "1.4.0",
parsers: ["less"],
vscodeLanguageIds: ["less"],
})),
createLanguage(require("linguist-languages/data/SCSS.json"), () => ({
since: "1.4.0",
parsers: ["scss"],
vscodeLanguageIds: ["scss"],
})),
createLanguage(
require("linguist-languages/data/CSS.json"),
(data) => ({
since: "1.4.0",
parsers: ["css"],
vscodeLanguageIds: ["css"],
extensions: [
...data.extensions,
// WeiXin Style Sheets
(Weixin Mini Programs)
// https://developers.weixin.qq.com/miniprogram/en/dev/framework/view/wxs/
".wxss",
],
})
),
createLanguage(
require("linguist-languages/data/PostCSS.json"),
() => ({
since: "1.4.0",
parsers: ["css"],
vscodeLanguageIds: ["postcss"],
})
),
createLanguage(
require("linguist-languages/data/Less.json"),
() => ({
since: "1.4.0",
parsers: ["less"],
vscodeLanguageIds: ["less"],
})
),
createLanguage(
require("linguist-languages/data/SCSS.json"),
() => ({
since: "1.4.0",
parsers: ["scss"],
vscodeLanguageIds: ["scss"],
})
), ];
const printers = { diff --git a/repos/prettier/src/language-graphql/index.js b/repos/prettier/src/language-graphql/index.js index b991a850f..c3f9a6367 100644 --- a/repos/prettier/src/language-graphql/index.js +++ b/repos/prettier/src/language-graphql/index.js @@ -5,11 +5,14 @@ const printer = require("./printer-graphql"); const options = require("./options");
const languages = [
createLanguage(require("linguist-languages/data/GraphQL.json"), () => ({
since: "1.5.0",
parsers: ["graphql"],
vscodeLanguageIds: ["graphql"],
})),
createLanguage(
require("linguist-languages/data/GraphQL.json"),
() => ({
since: "1.5.0",
parsers: ["graphql"],
vscodeLanguageIds: ["graphql"],
})
), ];
const printers = { diff --git a/repos/prettier/src/language-handlebars/index.js b/repos/prettier/src/language-handlebars/index.js index 01e35dd96..be3e56fbb 100644 --- a/repos/prettier/src/language-handlebars/index.js +++ b/repos/prettier/src/language-handlebars/index.js @@ -4,11 +4,14 @@ const createLanguage = require("../utils/create-language"); const printer = require("./printer-glimmer");
const languages = [
createLanguage(require("linguist-languages/data/Handlebars.json"), () => ({
since: null, // unreleased
parsers: ["glimmer"],
vscodeLanguageIds: ["handlebars"],
})),
createLanguage(
require("linguist-languages/data/Handlebars.json"),
() => ({
since: null, // unreleased
parsers: ["glimmer"],
vscodeLanguageIds: ["handlebars"],
})
), ];
const printers = { diff --git a/repos/prettier/src/language-html/index.js b/repos/prettier/src/language-html/index.js index 61882c524..b4e28ee9c 100644 --- a/repos/prettier/src/language-html/index.js +++ b/repos/prettier/src/language-html/index.js @@ -5,35 +5,47 @@ const printer = require("./printer-html"); const options = require("./options");
const languages = [
createLanguage(require("linguist-languages/data/HTML.json"), () => ({
name: "Angular",
since: "1.15.0",
parsers: ["angular"],
vscodeLanguageIds: ["html"],
extensions: [".component.html"],
filenames: [],
})),
createLanguage(require("linguist-languages/data/HTML.json"), (data) => ({
since: "1.15.0",
parsers: ["html"],
vscodeLanguageIds: ["html"],
extensions: data.extensions.concat([
".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML
]),
})),
createLanguage(require("linguist-languages/data/HTML.json"), () => ({
name: "Lightning Web Components",
since: "1.17.0",
parsers: ["lwc"],
vscodeLanguageIds: ["html"],
extensions: [],
filenames: [],
})),
createLanguage(require("linguist-languages/data/Vue.json"), () => ({
since: "1.10.0",
parsers: ["vue"],
vscodeLanguageIds: ["vue"],
})),
createLanguage(
require("linguist-languages/data/HTML.json"),
() => ({
name: "Angular",
since: "1.15.0",
parsers: ["angular"],
vscodeLanguageIds: ["html"],
extensions: [".component.html"],
filenames: [],
})
),
createLanguage(
require("linguist-languages/data/HTML.json"),
(data) => ({
since: "1.15.0",
parsers: ["html"],
vscodeLanguageIds: ["html"],
extensions: data.extensions.concat([
".mjml", // MJML is considered XML in Linguist but it should be formatted as HTML
]),
})
),
createLanguage(
require("linguist-languages/data/HTML.json"),
() => ({
name: "Lightning Web Components",
since: "1.17.0",
parsers: ["lwc"],
vscodeLanguageIds: ["html"],
extensions: [],
filenames: [],
})
),
createLanguage(
require("linguist-languages/data/Vue.json"),
() => ({
since: "1.10.0",
parsers: ["vue"],
vscodeLanguageIds: ["vue"],
})
), ];
const printers = { diff --git a/repos/prettier/src/language-html/printer-html.js b/repos/prettier/src/language-html/printer-html.js index 0beeea663..2fb9a692a 100644 --- a/repos/prettier/src/language-html/printer-html.js +++ b/repos/prettier/src/language-html/printer-html.js @@ -210,8 +210,10 @@ function embed(path, print, textToDoc, options) { node.rawName, '="', group(
mapDoc(embeddedAttributeValueDoc, (doc) =>
typeof doc === "string" ? doc.replace(/"/g, """) : doc
mapDoc(
embeddedAttributeValueDoc,
(doc) =>
typeof doc === "string" ? doc.replace(/"/g, """) : doc ) ), '"', diff --git a/repos/prettier/src/language-js/embed.js b/repos/prettier/src/language-js/embed.js index 1797bf414..c03e81354 100644 --- a/repos/prettier/src/language-js/embed.js +++ b/repos/prettier/src/language-js/embed.js @@ -227,21 +227,24 @@ function uncook(cookedValue) { }
function escapeTemplateCharacters(doc, raw) {
return mapDoc(doc, (currentDoc) => {
if (!currentDoc.parts) {
return currentDoc;
}
const parts = currentDoc.parts.map((part) => {
if (typeof part === "string") {
return raw ? part.replace(/(\*)/g, "$1$1\\
") : uncook(part);
return mapDoc(
doc,
(currentDoc) => {
if (!currentDoc.parts) {
return currentDoc; }
return part;
});
const parts = currentDoc.parts.map((part) => {
if (typeof part === "string") {
return raw ? part.replace(/(\*)/g, "$1$1\\
") : uncook(part);
}
return part;
});
return { ...currentDoc, parts };
});
return { ...currentDoc, parts };
}
); }
function transformCssDoc(quasisDoc, parentNode, expressionDocs) { @@ -269,52 +272,60 @@ function replacePlaceholders(quasisDoc, expressionDocs) { }
let replaceCounter = 0;
const newDoc = mapDoc(quasisDoc, (doc) => {
if (!doc || !doc.parts || !doc.parts.length) {
return doc;
}
let { parts } = doc;
const atIndex = parts.indexOf("@");
const placeholderIndex = atIndex + 1;
if (
atIndex > -1 &&
typeof parts[placeholderIndex] === "string" &&
parts[placeholderIndex].startsWith("prettier-placeholder")
) {
// If placeholder is split, join it
const at = parts[atIndex];
const placeholder = parts[placeholderIndex];
const rest = parts.slice(placeholderIndex + 1);
parts = parts
.slice(0, atIndex)
.concat([at + placeholder])
.concat(rest);
}
const newDoc = mapDoc(
quasisDoc,
(doc) => {
if (!doc || !doc.parts || !doc.parts.length) {
return doc;
}
const replacedParts = [];
parts.forEach((part) => {
if (typeof part !== "string" || !part.includes("@prettier-placeholder")) {
replacedParts.push(part);
return;
let { parts } = doc;
const atIndex = parts.indexOf("@");
const placeholderIndex = atIndex + 1;
if (
atIndex > -1 &&
typeof parts[placeholderIndex] === "string" &&
parts[placeholderIndex].startsWith("prettier-placeholder")
) {
// If placeholder is split, join it
const at = parts[atIndex];
const placeholder = parts[placeholderIndex];
const rest = parts.slice(placeholderIndex + 1);
parts = parts
.slice(0, atIndex)
.concat([at + placeholder])
.concat(rest); }
// When we have multiple placeholders in one line, like:
// ${Child}${Child2}:not(:first-child)
part.split(/@prettier-placeholder-(\d+)-id/).forEach((component, idx) => {
// The placeholder is always at odd indices
if (idx % 2 === 0) {
replacedParts.push(replaceNewlinesWithLiterallines(component));
const replacedParts = [];
parts.forEach((part) => {
if (
typeof part !== "string" ||
!part.includes("@prettier-placeholder")
) {
replacedParts.push(part); return; }
// The component will always be a number at odd index
replacedParts.push(expressionDocs[component]);
replaceCounter++;
// When we have multiple placeholders in one line, like:
// ${Child}${Child2}:not(:first-child)
part
.split(/@prettier-placeholder-(\d+)-id/)
.forEach((component, idx) => {
// The placeholder is always at odd indices
if (idx % 2 === 0) {
replacedParts.push(replaceNewlinesWithLiterallines(component));
return;
}
// The component will always be a number at odd index
replacedParts.push(expressionDocs[component]);
replaceCounter++;
}); });
});
return { ...doc, parts: replacedParts };
});
return { ...doc, parts: replacedParts };
}
); return expressionDocs.length === replaceCounter ? newDoc : null; }
diff --git a/repos/prettier/src/language-js/index.js b/repos/prettier/src/language-js/index.js index 00c22e142..465a6f280 100644 --- a/repos/prettier/src/language-js/index.js +++ b/repos/prettier/src/language-js/index.js @@ -27,52 +27,70 @@ const languages = [ ], }) ),
createLanguage(require("linguist-languages/data/JavaScript.json"), () => ({
name: "Flow",
since: "0.0.0",
parsers: ["flow", "babel-flow"],
vscodeLanguageIds: ["javascript"],
aliases: [],
filenames: [],
extensions: [".js.flow"],
})),
createLanguage(require("linguist-languages/data/JSX.json"), () => ({
since: "0.0.0",
parsers: [
"babel",
"babel-flow",
"babel-ts",
"flow",
"typescript",
"espree",
],
vscodeLanguageIds: ["javascriptreact"],
})),
createLanguage(require("linguist-languages/data/TypeScript.json"), () => ({
since: "1.4.0",
parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescript"],
})),
createLanguage(require("linguist-languages/data/TSX.json"), () => ({
since: "1.4.0",
parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescriptreact"],
})),
createLanguage(require("linguist-languages/data/JSON.json"), () => ({
name: "JSON.stringify",
since: "1.13.0",
parsers: ["json-stringify"],
vscodeLanguageIds: ["json"],
extensions: [], // .json file defaults to json instead of json-stringify
filenames: ["package.json", "package-lock.json", "composer.json"],
})),
createLanguage(require("linguist-languages/data/JSON.json"), (data) => ({
since: "1.5.0",
parsers: ["json"],
vscodeLanguageIds: ["json"],
filenames: [...data.filenames, ".prettierrc"],
extensions: data.extensions.filter((extension) => extension !== ".jsonl"),
})),
createLanguage(
require("linguist-languages/data/JavaScript.json"),
() => ({
name: "Flow",
since: "0.0.0",
parsers: ["flow", "babel-flow"],
vscodeLanguageIds: ["javascript"],
aliases: [],
filenames: [],
extensions: [".js.flow"],
})
),
createLanguage(
require("linguist-languages/data/JSX.json"),
() => ({
since: "0.0.0",
parsers: [
"babel",
"babel-flow",
"babel-ts",
"flow",
"typescript",
"espree",
],
vscodeLanguageIds: ["javascriptreact"],
})
),
createLanguage(
require("linguist-languages/data/TypeScript.json"),
() => ({
since: "1.4.0",
parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescript"],
})
),
createLanguage(
require("linguist-languages/data/TSX.json"),
() => ({
since: "1.4.0",
parsers: ["typescript", "babel-ts"],
vscodeLanguageIds: ["typescriptreact"],
})
),
createLanguage(
require("linguist-languages/data/JSON.json"),
() => ({
name: "JSON.stringify",
since: "1.13.0",
parsers: ["json-stringify"],
vscodeLanguageIds: ["json"],
extensions: [], // .json file defaults to json instead of json-stringify
filenames: ["package.json", "package-lock.json", "composer.json"],
})
),
createLanguage(
require("linguist-languages/data/JSON.json"),
(data) => ({
since: "1.5.0",
parsers: ["json"],
vscodeLanguageIds: ["json"],
filenames: [...data.filenames, ".prettierrc"],
extensions: data.extensions.filter((extension) => extension !== ".jsonl"),
})
), createLanguage( require("linguist-languages/data/JSON with Comments.json"), (data) => ({ @@ -82,11 +100,14 @@ const languages = [ filenames: [...data.filenames, ".eslintrc"], }) ),
createLanguage(require("linguist-languages/data/JSON5.json"), () => ({
since: "1.13.0",
parsers: ["json5"],
vscodeLanguageIds: ["json5"],
})),
createLanguage(
require("linguist-languages/data/JSON5.json"),
() => ({
since: "1.13.0",
parsers: ["json5"],
vscodeLanguageIds: ["json5"],
})
), ];
const printers = { diff --git a/repos/prettier/src/language-js/postprocess.js b/repos/prettier/src/language-js/postprocess.js index 26f4049cf..6d23aee6e 100644 --- a/repos/prettier/src/language-js/postprocess.js +++ b/repos/prettier/src/language-js/postprocess.js @@ -29,107 +29,116 @@ function postprocess(ast, options) { // E.g.: /* @type {Foo} / (foo).bar(); // Let's use the fact that those ancestors and ParenthesizedExpression have the same start offset.
ast = visitNode(ast, (node) => {
if (
node.leadingComments &&
node.leadingComments.some(isTypeCastComment)
) {
startOffsetsOfTypeCastedNodes.add(locStart(node));
}
});
ast = visitNode(ast, (node) => {
if (node.type === "ParenthesizedExpression") {
const { expression } = node;
// Align range with flow
if (expression.type === "TypeCastExpression") {
expression.range = node.range;
return expression;
ast = visitNode(
ast,
(node) => {
if (
node.leadingComments &&
node.leadingComments.some(isTypeCastComment)
) {
startOffsetsOfTypeCastedNodes.add(locStart(node)); }
}
);
ast = visitNode(
ast,
(node) => {
if (node.type === "ParenthesizedExpression") {
const { expression } = node;
// Align range with flow
if (expression.type === "TypeCastExpression") {
expression.range = node.range;
return expression;
}
const start = locStart(node);
if (!startOffsetsOfTypeCastedNodes.has(start)) {
if (!expression.extra) {
expression.extra = {};
const start = locStart(node);
if (!startOffsetsOfTypeCastedNodes.has(start)) {
if (!expression.extra) {
expression.extra = {};
}
expression.extra.parenthesized = true;
expression.extra.parenStart = start;
return expression; }
expression.extra.parenthesized = true;
expression.extra.parenStart = start;
return expression; } }
});
); }
ast = visitNode(ast, (node) => {
switch (node.type) {
// Espree
case "ChainExpression": {
return transformChainExpression(node.expression);
}
case "LogicalExpression": {
// We remove unneeded parens around same-operator LogicalExpressions
if (isUnbalancedLogicalTree(node)) {
return rebalanceLogicalTree(node);
ast = visitNode(
ast,
(node) => {
switch (node.type) {
// Espree
case "ChainExpression": {
return transformChainExpression(node.expression); }
break;
}
// fix unexpected locEnd caused by --no-semi style
case "VariableDeclaration": {
const lastDeclaration = getLast(node.declarations);
if (lastDeclaration && lastDeclaration.init) {
overrideLocEnd(node, lastDeclaration);
case "LogicalExpression": {
// We remove unneeded parens around same-operator LogicalExpressions
if (isUnbalancedLogicalTree(node)) {
return rebalanceLogicalTree(node);
}
break; }
break;
}
// remove redundant TypeScript nodes
case "TSParenthesizedType": {
node.typeAnnotation.range = composeLoc(node);
return node.typeAnnotation;
}
case "TSUnionType":
case "TSIntersectionType":
if (node.types.length === 1) {
const [firstType] = node.types;
// override loc, so that comments are attached properly
firstType.range = composeLoc(node);
return firstType;
// fix unexpected locEnd caused by --no-semi style
case "VariableDeclaration": {
const lastDeclaration = getLast(node.declarations);
if (lastDeclaration && lastDeclaration.init) {
overrideLocEnd(node, lastDeclaration);
}
break; }
break;
case "TSTypeParameter":
// babel-ts
if (typeof node.name === "string") {
node.name = {
type: "Identifier",
name: node.name,
range: composeLoc(node, node.name.length),
};
// remove redundant TypeScript nodes
case "TSParenthesizedType": {
node.typeAnnotation.range = composeLoc(node);
return node.typeAnnotation; }
break;
case "SequenceExpression": {
// Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this.
const lastExpression = getLast(node.expressions);
if (locEnd(node) > locEnd(lastExpression)) {
node.range = composeLoc(node, lastExpression);
case "TSUnionType":
case "TSIntersectionType":
if (node.types.length === 1) {
const [firstType] = node.types;
// override loc, so that comments are attached properly
firstType.range = composeLoc(node);
return firstType;
}
break;
case "TSTypeParameter":
// babel-ts
if (typeof node.name === "string") {
node.name = {
type: "Identifier",
name: node.name,
range: composeLoc(node, node.name.length),
};
}
break;
case "SequenceExpression": {
// Babel (unlike other parsers) includes spaces and comments in the range. Let's unify this.
const lastExpression = getLast(node.expressions);
if (locEnd(node) > locEnd(lastExpression)) {
node.range = composeLoc(node, lastExpression);
}
break; }
break;
case "ClassProperty":
// TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
if (
node.key &&
node.key.type === "TSPrivateIdentifier" &&
getNextNonSpaceNonCommentCharacter(
options.originalText,
node.key,
locEnd
) === "?"
) {
node.optional = true;
}
break; }
case "ClassProperty":
// TODO: Temporary auto-generated node type. To remove when typescript-estree has proper support for private fields.
if (
node.key &&
node.key.type === "TSPrivateIdentifier" &&
getNextNonSpaceNonCommentCharacter(
options.originalText,
node.key,
locEnd
) === "?"
) {
node.optional = true;
}
break; }
});
);
return ast;
diff --git a/repos/prettier/src/language-js/utils.js b/repos/prettier/src/language-js/utils.js index f3bf1f0a6..f7470cbd3 100644 --- a/repos/prettier/src/language-js/utils.js +++ b/repos/prettier/src/language-js/utils.js @@ -619,16 +619,19 @@ function hasDanglingComments(node) {
@returns {boolean} */ function hasNgSideEffect(path) {
function isNgForOf(node, index, parentNode) { diff --git a/repos/prettier/src/language-markdown/index.js b/repos/prettier/src/language-markdown/index.js index 318a691a4..f141b54f5 100644 --- a/repos/prettier/src/language-markdown/index.js +++ b/repos/prettier/src/language-markdown/index.js @@ -5,21 +5,27 @@ const printer = require("./printer-markdown"); const options = require("./options");
const languages = [
const printers = { diff --git a/repos/prettier/src/language-markdown/parser-markdown.js b/repos/prettier/src/language-markdown/parser-markdown.js index bb961f103..7871e904c 100644 --- a/repos/prettier/src/language-markdown/parser-markdown.js +++ b/repos/prettier/src/language-markdown/parser-markdown.js @@ -48,17 +48,20 @@ function identity(x) {
function htmlToJsx() { return (ast) =>
function frontMatter() { diff --git a/repos/prettier/src/language-markdown/preprocess.js b/repos/prettier/src/language-markdown/preprocess.js index 5b97c7e42..5f4724e00 100644 --- a/repos/prettier/src/language-markdown/preprocess.js +++ b/repos/prettier/src/language-markdown/preprocess.js @@ -19,45 +19,54 @@ function preprocess(ast, options) { }
function transformImportExport(ast) {
return { ...node, type: "importExport" };
});
return { ...node, type: "importExport" };
}
); }
function transformInlineCode(ast) {
return mapAst(ast, (node) => {
if (node.type !== "inlineCode") {
return node;
}
return mapAst(
ast,
(node) => {
if (node.type !== "inlineCode") {
return node;
}
return { ...node, value: node.value.replace(/\s+/g, " ") };
});
return { ...node, value: node.value.replace(/\s+/g, " ") };
}
); }
function restoreUnescapedCharacter(ast, options) {
return mapAst(ast, (node) => {
return node.type !== "text"
? node
: {
...node,
value:
node.value !== "*" &&
node.value !== "_" &&
node.value !== "$" && // handle these cases in printer
isSingleCharRegex.test(node.value) &&
node.position.end.offset - node.position.start.offset !==
node.value.length
? options.originalText.slice(
node.position.start.offset,
node.position.end.offset
)
: node.value,
};
});
return mapAst(
ast,
(node) => {
return node.type !== "text"
? node
: {
...node,
value:
node.value !== "*" &&
node.value !== "_" &&
node.value !== "$" && // handle these cases in printer
isSingleCharRegex.test(node.value) &&
node.position.end.offset - node.position.start.offset !==
node.value.length
? options.originalText.slice(
node.position.start.offset,
node.position.end.offset
)
: node.value,
};
}
); }
function mergeContinuousImportExport(ast) { @@ -77,21 +86,24 @@ function mergeContinuousImportExport(ast) { }
function mergeChildren(ast, shouldMerge, mergeNode) {
return mapAst(ast, (node) => {
if (!node.children) {
return node;
}
const children = node.children.reduce((current, child) => {
const lastChild = current[current.length - 1];
if (lastChild && shouldMerge(lastChild, child)) {
current.splice(-1, 1, mergeNode(lastChild, child));
} else {
current.push(child);
return mapAst(
ast,
(node) => {
if (!node.children) {
return node; }
return current;
}, []);
return { ...node, children };
});
const children = node.children.reduce((current, child) => {
const lastChild = current[current.length - 1];
if (lastChild && shouldMerge(lastChild, child)) {
current.splice(-1, 1, mergeNode(lastChild, child));
} else {
current.push(child);
}
return current;
}, []);
return { ...node, children };
}
); }
function mergeContinuousTexts(ast) { @@ -110,79 +122,88 @@ function mergeContinuousTexts(ast) { }
function splitTextIntoSentences(ast, options) {
return mapAst(ast, (node, index, [parentNode]) => {
if (node.type !== "text") {
return node;
}
return mapAst(
ast,
(node, index, [parentNode]) => {
if (node.type !== "text") {
return node;
}
let { value } = node;
let { value } = node;
if (parentNode.type === "paragraph") {
if (index === 0) {
value = value.trimStart();
}
if (index === parentNode.children.length - 1) {
value = value.trimEnd();
if (parentNode.type === "paragraph") {
if (index === 0) {
value = value.trimStart();
}
if (index === parentNode.children.length - 1) {
value = value.trimEnd();
} }
}
return {
type: "sentence",
position: node.position,
children: splitText(value, options),
};
});
return {
type: "sentence",
position: node.position,
children: splitText(value, options),
};
}
); }
function transformIndentedCodeblockAndMarkItsParentList(ast, options) {
return mapAst(ast, (node, index, parentStack) => {
if (node.type === "code") {
// the first char may point to \n
, e.g. \n\t\tbar
, just ignore it
const isIndented = /^\n?( {4,}|\t)/.test(
options.originalText.slice(
node.position.start.offset,
node.position.end.offset
)
);
node.isIndented = isIndented;
if (isIndented) {
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i];
// no need to check checked items
if (parent.hasIndentedCodeblock) {
break;
}
if (parent.type === "list") {
parent.hasIndentedCodeblock = true;
return mapAst(
ast,
(node, index, parentStack) => {
if (node.type === "code") {
// the first char may point to \n
, e.g. \n\t\tbar
, just ignore it
const isIndented = /^\n?( {4,}|\t)/.test(
options.originalText.slice(
node.position.start.offset,
node.position.end.offset
)
);
node.isIndented = isIndented;
if (isIndented) {
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i];
// no need to check checked items
if (parent.hasIndentedCodeblock) {
break;
}
if (parent.type === "list") {
parent.hasIndentedCodeblock = true;
} } } }
return node; }
return node;
});
); }
function markAlignedList(ast, options) {
return mapAst(ast, (node, index, parentStack) => {
if (node.type === "list" && node.children.length !== 0) {
// if one of its parents is not aligned, it's not possible to be aligned in sub-lists
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i];
if (parent.type === "list" && !parent.isAligned) {
node.isAligned = false;
return node;
return mapAst(
ast,
(node, index, parentStack) => {
if (node.type === "list" && node.children.length !== 0) {
// if one of its parents is not aligned, it's not possible to be aligned in sub-lists
for (let i = 0; i < parentStack.length; i++) {
const parent = parentStack[i];
if (parent.type === "list" && !parent.isAligned) {
node.isAligned = false;
return node;
} }
node.isAligned = isAligned(node); }
node.isAligned = isAligned(node);
return node; }
return node;
});
);
function getListItemStart(listItem) { return listItem.children.length === 0 diff --git a/repos/prettier/src/language-markdown/printer-markdown.js b/repos/prettier/src/language-markdown/printer-markdown.js index 5b743215f..6a6272451 100644 --- a/repos/prettier/src/language-markdown/printer-markdown.js +++ b/repos/prettier/src/language-markdown/printer-markdown.js @@ -124,8 +124,9 @@ function genericPrint(path, options, print) { )) ) { // backslash is parsed as part of autolinks, so we need to remove it
escapedValue = escapedValue.replace(/^(\?[*_])+/, (prefix) =>
prefix.replace(/\/g, "")
escapedValue = escapedValue.replace(
/^(\?[*_])+/,
(prefix) => prefix.replace(/\/g, "") ); }
diff --git a/repos/prettier/src/language-yaml/index.js b/repos/prettier/src/language-yaml/index.js index 158de2d73..4ba007d8f 100644 --- a/repos/prettier/src/language-yaml/index.js +++ b/repos/prettier/src/language-yaml/index.js @@ -5,13 +5,16 @@ const printer = require("./printer-yaml"); const options = require("./options");
const languages = [
createLanguage(require("linguist-languages/data/YAML.json"), (data) => ({
since: "1.14.0",
parsers: ["yaml"],
vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
// yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629
filenames: data.filenames.filter((filename) => filename !== "yarn.lock"),
})),
createLanguage(
require("linguist-languages/data/YAML.json"),
(data) => ({
since: "1.14.0",
parsers: ["yaml"],
vscodeLanguageIds: ["yaml", "ansible", "home-assistant"],
// yarn.lock is not YAML: https://github.com/yarnpkg/yarn/issues/5629
filenames: data.filenames.filter((filename) => filename !== "yarn.lock"),
})
), ];
const parsers = { diff --git a/repos/prettier/src/language-yaml/printer-yaml.js b/repos/prettier/src/language-yaml/printer-yaml.js index f13df3580..640b22c5c 100644 --- a/repos/prettier/src/language-yaml/printer-yaml.js +++ b/repos/prettier/src/language-yaml/printer-yaml.js @@ -329,8 +329,9 @@ function _print(node, parentNode, path, options, print) { } case "blockFolded": case "blockLiteral": {
const parentIndent = getAncestorCount(path, (ancestorNode) =>
isNode(ancestorNode, ["sequence", "mapping"])
const parentIndent = getAncestorCount(
path,
(ancestorNode) => isNode(ancestorNode, ["sequence", "mapping"]) ); const isLastDescendant = isLastDescendantNode(path); return concat([ diff --git a/repos/prettier/tests_config/utils/stringify-options-for-title.js b/repos/prettier/tests_config/utils/stringify-options-for-title.js index 2ea06ce77..7e54944d2 100644 --- a/repos/prettier/tests_config/utils/stringify-options-for-title.js +++ b/repos/prettier/tests_config/utils/stringify-options-for-title.js @@ -1,12 +1,14 @@ "use strict";
function stringifyOptions(options) {
const string = JSON.stringify(options || {}, (key, value) =>
key === "plugins" || key === "errors"
? undefined
: value === Infinity
? "Infinity"
: value
const string = JSON.stringify(
options || {},
(key, value) =>
key === "plugins" || key === "errors"
? undefined
: value === Infinity
? "Infinity"
: value );
return string === "{}" ? "" : string; Submodule repos/typescript-eslint contains modified content diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts index f0904f07..b7987274 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/explicit-function-return-type.ts @@ -82,21 +82,29 @@ export default util.createRule<Options, MessageIds>({ return; }
checkFunctionExpressionReturnType(node, options, sourceCode, loc =>
context.report({
node,
loc,
messageId: 'missingReturnType',
}),
checkFunctionExpressionReturnType(
node,
options,
sourceCode,
loc =>
context.report({
node,
loc,
messageId: 'missingReturnType',
}), ); }, FunctionDeclaration(node): void {
checkFunctionReturnType(node, options, sourceCode, loc =>
context.report({
node,
loc,
messageId: 'missingReturnType',
}),
checkFunctionReturnType(
node,
options,
sourceCode,
loc =>
context.report({
node,
loc,
messageId: 'missingReturnType',
}), ); }, }; diff --git a/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts b/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts index 2ff89c59..9a3d132c 100644 --- a/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts +++ b/repos/typescript-eslint/packages/eslint-plugin/src/rules/no-unnecessary-type-arguments.ts @@ -117,12 +117,14 @@ function getTypeParametersFromType( return undefined; }
return findFirstResult(declarations, decl =>
tsutils.isClassLikeDeclaration(decl) ||
ts.isTypeAliasDeclaration(decl) ||
ts.isInterfaceDeclaration(decl)
? decl.typeParameters
: undefined,
return findFirstResult(
declarations,
decl =>
tsutils.isClassLikeDeclaration(decl) ||
ts.isTypeAliasDeclaration(decl) ||
ts.isInterfaceDeclaration(decl)
? decl.typeParameters
: undefined, ); }
diff --git a/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts b/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts index 74c58666..b976e9c9 100644 --- a/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts +++ b/repos/typescript-eslint/packages/typescript-estree/src/node-utils.ts @@ -367,16 +367,19 @@ export function findNextToken( // this is token that starts at the end of previous token - return it return n; }
run with pr 9672