Migrate format test to ES Module (#11902)
Co-authored-by: Sosuke Suzuki <aosukeke@gmail.com>
This commit is contained in:
1 parent
d9ca78e156
commit
6bd81c23b6
1161 files changed
+1937
-1425
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
/tests/format/**/*.js
|
/tests/format/**/*.js
|
||||||
/tests/integration/cli/
|
/tests/integration/cli/
|
||||||
!/tests/format/**/jsfmt.spec.js
|
!/tests/format/**/jsfmt.spec.js
|
||||||
|
/tests/config/jest-light-runner/**/*
|
||||||
!/**/.eslintrc.js
|
!/**/.eslintrc.js
|
||||||
/test*.*
|
/test*.*
|
||||||
/scripts/release/node_modules
|
/scripts/release/node_modules
|
||||||
|
|||||||
+2
-12
@@ -151,11 +151,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: [
|
files: ["**/*.mjs", "scripts/release/**/*.js", "tests/**/*.js"],
|
||||||
"**/*.mjs",
|
|
||||||
"scripts/release/**/*.js",
|
|
||||||
"tests/integration/**/*.js",
|
|
||||||
],
|
|
||||||
excludedFiles: [
|
excludedFiles: [
|
||||||
"tests/integration/plugins/automatic/prettier-plugin-bar.js",
|
"tests/integration/plugins/automatic/prettier-plugin-bar.js",
|
||||||
],
|
],
|
||||||
@@ -167,13 +163,6 @@ module.exports = {
|
|||||||
"unicorn/prefer-node-protocol": "error",
|
"unicorn/prefer-node-protocol": "error",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// There is a empty package.json in that directory
|
|
||||||
{
|
|
||||||
files: ["tests/integration/**/*.js"],
|
|
||||||
rules: {
|
|
||||||
"import/no-extraneous-dependencies": "off",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
files: [
|
files: [
|
||||||
"tests/format/**/jsfmt.spec.js",
|
"tests/format/**/jsfmt.spec.js",
|
||||||
@@ -205,6 +194,7 @@ module.exports = {
|
|||||||
files: ["tests/**/*.js"],
|
files: ["tests/**/*.js"],
|
||||||
rules: {
|
rules: {
|
||||||
strict: "off",
|
strict: "off",
|
||||||
|
"import/no-extraneous-dependencies": "off",
|
||||||
"unicorn/prefer-array-flat": "off",
|
"unicorn/prefer-array-flat": "off",
|
||||||
"unicorn/prefer-array-flat-map": "off",
|
"unicorn/prefer-array-flat-map": "off",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -47,4 +47,7 @@ jobs:
|
|||||||
run: npm install --global pnpm
|
run: npm install --global pnpm
|
||||||
|
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: yarn test:dev-package --maxWorkers=2
|
run: yarn test:dev-package:integration --maxWorkers=2
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: yarn test:dev-package:format --maxWorkers=2
|
||||||
@@ -56,13 +56,27 @@ jobs:
|
|||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
- name: Run Tests (macOS)
|
- name: Run Integration Tests (macOS)
|
||||||
if: ${{ matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
run: yarn test --maxWorkers=4
|
run: yarn test:integration --maxWorkers=4
|
||||||
|
|
||||||
- name: Run Tests (Linux and Windows)
|
- name: Run Integration Tests (Linux and Windows)
|
||||||
if: ${{ matrix.os != 'macos-latest' }}
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
run: yarn test --maxWorkers=2
|
run: yarn test:integration --maxWorkers=2
|
||||||
|
|
||||||
|
- name: Upload Coverage
|
||||||
|
uses: codecov/codecov-action@v2.1.0
|
||||||
|
if: ${{ matrix.ENABLE_CODE_COVERAGE }}
|
||||||
|
with:
|
||||||
|
fail_ci_if_error: true
|
||||||
|
|
||||||
|
- name: Run Format Tests (macOS)
|
||||||
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
|
run: yarn test:format --maxWorkers=4
|
||||||
|
|
||||||
|
- name: Run Format Tests (Linux and Windows)
|
||||||
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
|
run: yarn c8 yarn test:format --maxWorkers=2
|
||||||
|
|
||||||
- name: Upload Coverage
|
- name: Upload Coverage
|
||||||
uses: codecov/codecov-action@v2.1.0
|
uses: codecov/codecov-action@v2.1.0
|
||||||
@@ -72,7 +86,7 @@ jobs:
|
|||||||
|
|
||||||
# #8073 test
|
# #8073 test
|
||||||
- name: Run Tests (PRETTIER_FALLBACK_RESOLVE)
|
- name: Run Tests (PRETTIER_FALLBACK_RESOLVE)
|
||||||
run: yarn test "tests/integration/__tests__/(config|plugin)"
|
run: yarn c8 yarn test:integration "tests/integration/__tests__/(config|plugin)"
|
||||||
env:
|
env:
|
||||||
PRETTIER_FALLBACK_RESOLVE: true
|
PRETTIER_FALLBACK_RESOLVE: true
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
- name: Lint Code
|
- name: Lint Code
|
||||||
run: yarn lint:dist
|
run: yarn test:dist:lint
|
||||||
|
|
||||||
test:
|
test:
|
||||||
timeout-minutes: 90
|
timeout-minutes: 90
|
||||||
@@ -125,25 +125,33 @@ jobs:
|
|||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
- name: Run Tests (macOS)
|
- name: Run Integration Tests (macOS)
|
||||||
if: ${{ matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
run: yarn test:dist --maxWorkers=4
|
run: yarn test:dist:integration --maxWorkers=4
|
||||||
|
|
||||||
- name: Run Tests (Linux and Windows)
|
- name: Run Integration Tests (Linux and Windows)
|
||||||
if: ${{ matrix.os != 'macos-latest' }}
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
run: yarn test:dist --maxWorkers=2
|
run: yarn test:dist:integration --maxWorkers=2
|
||||||
|
|
||||||
- name: Run Tests (standalone) (macOS)
|
- name: Run Format Tests (macOS)
|
||||||
if: ${{ matrix.os == 'macos-latest' }}
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
run: yarn test:dist-standalone --maxWorkers=4
|
run: yarn test:dist:format --maxWorkers=4
|
||||||
|
|
||||||
- name: Run Tests (standalone) (Linux and Windows)
|
- name: Run Format Tests (Linux and Windows)
|
||||||
if: ${{ matrix.os != 'macos-latest' }}
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
run: yarn test:dist-standalone --maxWorkers=2
|
run: yarn test:dist:format --maxWorkers=2
|
||||||
|
|
||||||
|
- name: Run Format Tests (standalone) (macOS)
|
||||||
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
|
run: yarn test:dist:standalone:format --maxWorkers=4
|
||||||
|
|
||||||
|
- name: Run Format Tests (standalone) (Linux and Windows)
|
||||||
|
if: ${{ matrix.os != 'macos-latest' }}
|
||||||
|
run: yarn test:dist:standalone:format --maxWorkers=2
|
||||||
|
|
||||||
# #8073 test
|
# #8073 test
|
||||||
- name: Run Tests (PRETTIER_FALLBACK_RESOLVE)
|
- name: Run Tests (PRETTIER_FALLBACK_RESOLVE)
|
||||||
run: yarn test "tests/integration/__tests__/(config|plugin)"
|
run: yarn test:dist:integration "tests/integration/__tests__/(config|plugin)"
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
PRETTIER_FALLBACK_RESOLVE: true
|
PRETTIER_FALLBACK_RESOLVE: true
|
||||||
@@ -6,6 +6,7 @@ coverage/
|
|||||||
/tests/integration/cli/
|
/tests/integration/cli/
|
||||||
/tests/integration/plugins/
|
/tests/integration/plugins/
|
||||||
/tests/integration/custom-parsers/
|
/tests/integration/custom-parsers/
|
||||||
|
/tests/config/jest-light-runner/**/*
|
||||||
/website/build/
|
/website/build/
|
||||||
/website/static/lib/
|
/website/static/lib/
|
||||||
/website/static/playground.js
|
/website/static/playground.js
|
||||||
|
|||||||
+5
-5
@@ -14,7 +14,7 @@ The tests use [Jest snapshots](https://facebook.github.io/jest/docs/en/snapshot-
|
|||||||
Each test directory in `tests/format` has a `jsfmt.spec.js` file that controls how exactly the rest of the files in the directory are used for tests. This file must contain one or more calls to the `run_spec` global function. For example, in directories with JavaScript formatting tests, `jsfmt.spec.js` generally looks like this:
|
Each test directory in `tests/format` has a `jsfmt.spec.js` file that controls how exactly the rest of the files in the directory are used for tests. This file must contain one or more calls to the `run_spec` global function. For example, in directories with JavaScript formatting tests, `jsfmt.spec.js` generally looks like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
run_spec(__dirname, ["babel", "flow", "typescript"]);
|
run_spec(import.meta, ["babel", "flow", "typescript"]);
|
||||||
```
|
```
|
||||||
|
|
||||||
This verifies that for each file in the directory, the output matches the snapshot and is the same for each listed parser.
|
This verifies that for each file in the directory, the output matches the snapshot and is the same for each listed parser.
|
||||||
@@ -22,7 +22,7 @@ This verifies that for each file in the directory, the output matches the snapsh
|
|||||||
You can also pass options as the third argument:
|
You can also pass options as the third argument:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
run_spec(__dirname, ["babel"], { trailingComma: "es5" });
|
run_spec(import.meta, ["babel"], { trailingComma: "es5" });
|
||||||
```
|
```
|
||||||
|
|
||||||
Signature:
|
Signature:
|
||||||
@@ -30,9 +30,9 @@ Signature:
|
|||||||
```ts
|
```ts
|
||||||
function run_spec(
|
function run_spec(
|
||||||
fixtures:
|
fixtures:
|
||||||
| string
|
| ImportMeta
|
||||||
| {
|
| {
|
||||||
dirname: string;
|
importMeta: ImportMeta;
|
||||||
snippets?: Array<
|
snippets?: Array<
|
||||||
| string
|
| string
|
||||||
| { code: string; name?: string; filename?: string; output?: string }
|
| { code: string; name?: string; filename?: string; output?: string }
|
||||||
@@ -47,7 +47,7 @@ function run_spec(
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
|
||||||
- **`fixtures`**: Must be set to `__dirname` or to an object of the shape `{ dirname: __dirname, ... }`. The object may have the `snippets` property to specify an array of extra input entries in addition to the files in the current directory. For each input entry (a file or a snippet), `run_spec` configures and runs a number of tests. The main check is that for a given input the output should match the snapshot (for snippets, the expected output can also be specified directly). [Additional checks](#deeper-testing) are controlled by options and environment variables.
|
- **`fixtures`**: Must be set to `import.meta` or to an object of the shape `{ importMeta: import.meta, ... }`. The object may have the `snippets` property to specify an array of extra input entries in addition to the files in the current directory. For each input entry (a file or a snippet), `run_spec` configures and runs a number of tests. The main check is that for a given input the output should match the snapshot (for snippets, the expected output can also be specified directly). [Additional checks](#deeper-testing) are controlled by options and environment variables.
|
||||||
- **`parsers`**: A list of parser names. The tests verify that the parsers in this list produce the same output. If the list includes `typescript`, then `babel-ts` is included implicitly. If the list includes `babel`, and the current directory is inside `tests/format/js`, then `espree` and `meriyah` are included implicitly.
|
- **`parsers`**: A list of parser names. The tests verify that the parsers in this list produce the same output. If the list includes `typescript`, then `babel-ts` is included implicitly. If the list includes `babel`, and the current directory is inside `tests/format/js`, then `espree` and `meriyah` are included implicitly.
|
||||||
- **`options`**: In addition to Prettier's formatting options, can contain the `errors` property to specify that it's expected that the formatting shouldn't be successful and an error should be thrown for all (`errors: true`) or some combinations of input entries and parsers.
|
- **`options`**: In addition to Prettier's formatting options, can contain the `errors` property to specify that it's expected that the formatting shouldn't be successful and an error should be thrown for all (`errors: true`) or some combinations of input entries and parsers.
|
||||||
|
|
||||||
|
|||||||
@@ -382,6 +382,7 @@
|
|||||||
"**/yarn.lock",
|
"**/yarn.lock",
|
||||||
"*.{log,svg,snap,png}",
|
"*.{log,svg,snap,png}",
|
||||||
"test*.*",
|
"test*.*",
|
||||||
|
"tests/config/jest-light-runner/**/*",
|
||||||
"website/data/users.yml",
|
"website/data/users.yml",
|
||||||
"website/build/**",
|
"website/build/**",
|
||||||
"website/playground/codeSamples.mjs",
|
"website/playground/codeSamples.mjs",
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import baseConfig from "./jest.config.mjs";
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
runner: "./tests/config/jest-light-runner",
|
||||||
|
testRegex: "tests/format/.*/jsfmt\\.spec\\.js$",
|
||||||
|
...baseConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import baseConfig from "./jest.config.mjs";
|
||||||
|
|
||||||
|
const config = {
|
||||||
|
testRegex: "tests/integration/__tests__/.*\\.js$",
|
||||||
|
...baseConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
+4
-4
@@ -1,7 +1,8 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import createEsmUtils from "esm-utils";
|
import createEsmUtils from "esm-utils";
|
||||||
import installPrettier from "./tests/config/install-prettier.mjs";
|
import installPrettier from "./tests/config/install-prettier.js";
|
||||||
|
|
||||||
|
// @ts-expect-error
|
||||||
const { dirname: PROJECT_ROOT } = createEsmUtils(import.meta);
|
const { dirname: PROJECT_ROOT } = createEsmUtils(import.meta);
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
const ENABLE_CODE_COVERAGE = Boolean(process.env.ENABLE_CODE_COVERAGE);
|
const ENABLE_CODE_COVERAGE = Boolean(process.env.ENABLE_CODE_COVERAGE);
|
||||||
@@ -33,7 +34,6 @@ const config = {
|
|||||||
"jest-snapshot-serializer-raw",
|
"jest-snapshot-serializer-raw",
|
||||||
"jest-snapshot-serializer-ansi",
|
"jest-snapshot-serializer-ansi",
|
||||||
],
|
],
|
||||||
testRegex: "jsfmt\\.spec\\.js$|__tests__/.*\\.js$",
|
|
||||||
testPathIgnorePatterns,
|
testPathIgnorePatterns,
|
||||||
collectCoverage: ENABLE_CODE_COVERAGE,
|
collectCoverage: ENABLE_CODE_COVERAGE,
|
||||||
collectCoverageFrom: ["<rootDir>/src/**/*.js", "<rootDir>/bin/**/*.js"],
|
collectCoverageFrom: ["<rootDir>/src/**/*.js", "<rootDir>/bin/**/*.js"],
|
||||||
@@ -43,8 +43,8 @@ const config = {
|
|||||||
],
|
],
|
||||||
coverageReporters: ["text", "lcov"],
|
coverageReporters: ["text", "lcov"],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
"prettier-local": "<rootDir>/tests/config/require-prettier.js",
|
"prettier-local": "<rootDir>/tests/config/require-prettier.cjs",
|
||||||
"prettier-standalone": "<rootDir>/tests/config/require-standalone.js",
|
"prettier-standalone": "<rootDir>/tests/config/require-standalone.cjs",
|
||||||
},
|
},
|
||||||
modulePathIgnorePatterns: [
|
modulePathIgnorePatterns: [
|
||||||
"<rootDir>/dist",
|
"<rootDir>/dist",
|
||||||
|
|||||||
+17
-7
@@ -29,6 +29,7 @@
|
|||||||
"@typescript-eslint/typescript-estree": "5.8.1",
|
"@typescript-eslint/typescript-estree": "5.8.1",
|
||||||
"angular-estree-parser": "2.5.0",
|
"angular-estree-parser": "2.5.0",
|
||||||
"angular-html-parser": "1.8.0",
|
"angular-html-parser": "1.8.0",
|
||||||
|
"c8": "7.10.0",
|
||||||
"camelcase": "6.3.0",
|
"camelcase": "6.3.0",
|
||||||
"chalk": "4.1.2",
|
"chalk": "4.1.2",
|
||||||
"ci-info": "3.3.0",
|
"ci-info": "3.3.0",
|
||||||
@@ -94,6 +95,7 @@
|
|||||||
"@babel/types": "7.16.7",
|
"@babel/types": "7.16.7",
|
||||||
"@glimmer/reference": "0.83.1",
|
"@glimmer/reference": "0.83.1",
|
||||||
"@jest/globals": "27.4.2",
|
"@jest/globals": "27.4.2",
|
||||||
|
"@prettier/jest-light-runner": "file:./tests/config/jest-light-runner",
|
||||||
"@rollup/plugin-alias": "3.1.9",
|
"@rollup/plugin-alias": "3.1.9",
|
||||||
"@rollup/plugin-babel": "5.3.0",
|
"@rollup/plugin-babel": "5.3.0",
|
||||||
"@rollup/plugin-commonjs": "21.0.1",
|
"@rollup/plugin-commonjs": "21.0.1",
|
||||||
@@ -120,8 +122,8 @@
|
|||||||
"eslint-plugin-react": "7.28.0",
|
"eslint-plugin-react": "7.28.0",
|
||||||
"eslint-plugin-regexp": "1.5.1",
|
"eslint-plugin-regexp": "1.5.1",
|
||||||
"eslint-plugin-unicorn": "40.0.0",
|
"eslint-plugin-unicorn": "40.0.0",
|
||||||
"execa": "6.0.0",
|
|
||||||
"esm-utils": "2.0.1",
|
"esm-utils": "2.0.1",
|
||||||
|
"execa": "6.0.0",
|
||||||
"jest": "27.4.5",
|
"jest": "27.4.5",
|
||||||
"jest-snapshot-serializer-ansi": "1.0.0",
|
"jest-snapshot-serializer-ansi": "1.0.0",
|
||||||
"jest-snapshot-serializer-raw": "1.2.0",
|
"jest-snapshot-serializer-raw": "1.2.0",
|
||||||
@@ -142,11 +144,14 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
"prepublishOnly": "echo \"Error: must publish from dist/\" && exit 1",
|
||||||
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
|
"test:integration": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config=jest-integration-test.config.mjs",
|
||||||
"test:dev-package": "cross-env INSTALL_PACKAGE=1 NODE_OPTIONS=--experimental-vm-modules jest",
|
"test:format": "jest --config=jest-format-test.config.mjs",
|
||||||
"test:dist": "cross-env NODE_ENV=production NODE_OPTIONS=--experimental-vm-modules jest",
|
"test:dev-package:integration": "cross-env INSTALL_PACKAGE=1 yarn test:integration",
|
||||||
"test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 NODE_OPTIONS=--experimental-vm-modules jest",
|
"test:dev-package:format": "cross-env INSTALL_PACKAGE=1 yarn test:format",
|
||||||
"test:integration": "cross-env NODE_OPTIONS=--experimental-vm-modules jest tests/integration",
|
"test:dist:lint": "eslint --no-eslintrc --no-ignore --no-inline-config --config=./scripts/bundle-eslint-config.js \"dist/!(bin-prettier|index|third-party).js\"",
|
||||||
|
"test:dist:integration": "cross-env NODE_ENV=production yarn test:integration",
|
||||||
|
"test:dist:format": "cross-env NODE_ENV=production yarn test:format",
|
||||||
|
"test:dist:standalone:format": "cross-env TEST_STANDALONE=1 yarn test:dist:format",
|
||||||
"perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
"perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||||
"perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
"perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||||
"perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
"perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
|
||||||
@@ -155,7 +160,6 @@
|
|||||||
"lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
|
"lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
|
||||||
"lint:changelog": "node ./scripts/lint-changelog.mjs",
|
"lint:changelog": "node ./scripts/lint-changelog.mjs",
|
||||||
"lint:prettier": "prettier . \"!test*\" --check",
|
"lint:prettier": "prettier . \"!test*\" --check",
|
||||||
"lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --config=./scripts/bundle-eslint-config.js \"dist/!(bin-prettier|index|third-party).js\"",
|
|
||||||
"lint:spellcheck": "cspell --no-progress --relative",
|
"lint:spellcheck": "cspell --no-progress --relative",
|
||||||
"lint:deps": "node ./scripts/check-deps.mjs",
|
"lint:deps": "node ./scripts/check-deps.mjs",
|
||||||
"lint:actionlint": "node-actionlint",
|
"lint:actionlint": "node-actionlint",
|
||||||
@@ -165,6 +169,12 @@
|
|||||||
"build": "node --max-old-space-size=4096 ./scripts/build/build.mjs",
|
"build": "node --max-old-space-size=4096 ./scripts/build/build.mjs",
|
||||||
"build:website": "node ./scripts/build-website.mjs"
|
"build:website": "node ./scripts/build-website.mjs"
|
||||||
},
|
},
|
||||||
|
"c8": {
|
||||||
|
"reporter": [
|
||||||
|
"lcov",
|
||||||
|
"text"
|
||||||
|
]
|
||||||
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
">0.5%",
|
">0.5%",
|
||||||
"not ie 11",
|
"not ie 11",
|
||||||
|
|||||||
+18
-14
@@ -1,17 +1,19 @@
|
|||||||
"use strict";
|
import fs from "node:fs";
|
||||||
|
import path from "node:path";
|
||||||
|
import url from "node:url";
|
||||||
|
import createEsmUtils from "esm-utils";
|
||||||
|
import checkParsers from "./utils/check-parsers.js";
|
||||||
|
import createSnapshot from "./utils/create-snapshot.js";
|
||||||
|
import visualizeEndOfLine from "./utils/visualize-end-of-line.js";
|
||||||
|
import consistentEndOfLine from "./utils/consistent-end-of-line.js";
|
||||||
|
import stringifyOptionsForTitle from "./utils/stringify-options-for-title.js";
|
||||||
|
|
||||||
|
const { require, __dirname } = createEsmUtils(import.meta);
|
||||||
|
|
||||||
const { TEST_STANDALONE } = process.env;
|
const { TEST_STANDALONE } = process.env;
|
||||||
|
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
const prettier = !TEST_STANDALONE
|
const prettier = !TEST_STANDALONE
|
||||||
? require("prettier-local")
|
? require("./require-prettier.cjs")
|
||||||
: require("prettier-standalone");
|
: require("./require-standalone.cjs");
|
||||||
const checkParsers = require("./utils/check-parsers.js");
|
|
||||||
const createSnapshot = require("./utils/create-snapshot.js");
|
|
||||||
const visualizeEndOfLine = require("./utils/visualize-end-of-line.js");
|
|
||||||
const consistentEndOfLine = require("./utils/consistent-end-of-line.js");
|
|
||||||
const stringifyOptionsForTitle = require("./utils/stringify-options-for-title.js");
|
|
||||||
|
|
||||||
const { FULL_TEST } = process.env;
|
const { FULL_TEST } = process.env;
|
||||||
const BOM = "\uFEFF";
|
const BOM = "\uFEFF";
|
||||||
@@ -98,8 +100,10 @@ const isTestDirectory = (dirname, name) =>
|
|||||||
);
|
);
|
||||||
|
|
||||||
function runSpec(fixtures, parsers, options) {
|
function runSpec(fixtures, parsers, options) {
|
||||||
let { dirname, snippets = [] } =
|
let { importMeta, snippets = [] } = fixtures.importMeta
|
||||||
typeof fixtures === "string" ? { dirname: fixtures } : fixtures;
|
? fixtures
|
||||||
|
: { importMeta: fixtures };
|
||||||
|
const dirname = path.dirname(url.fileURLToPath(importMeta.url));
|
||||||
|
|
||||||
// `IS_PARSER_INFERENCE_TESTS` mean to test `inferParser` on `standalone`
|
// `IS_PARSER_INFERENCE_TESTS` mean to test `inferParser` on `standalone`
|
||||||
const IS_PARSER_INFERENCE_TESTS = isTestDirectory(
|
const IS_PARSER_INFERENCE_TESTS = isTestDirectory(
|
||||||
@@ -445,4 +449,4 @@ function format(originalText, originalOptions) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = runSpec;
|
export default runSpec;
|
||||||
File renamed without changes.
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "@prettier/jest-light-runner",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"main": "./src/index.js",
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.js"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"expect": "^27.4.0",
|
||||||
|
"jest-circus": "^27.4.0",
|
||||||
|
"jest-each": "^27.4.0",
|
||||||
|
"jest-mock": "^27.4.0",
|
||||||
|
"jest-snapshot": "^27.4.0",
|
||||||
|
"piscina": "^3.1.0",
|
||||||
|
"supports-color": "^9.0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
> This package is copied from https://github.com/babel/babel/tree/main/test/jest-light-runner
|
||||||
|
|
||||||
|
Modifications:
|
||||||
|
|
||||||
|
- Added `setupFiles` support
|
||||||
|
- Added `snapshotSerializers` support
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/* eslint-disable import/extensions */
|
||||||
|
|
||||||
|
import mock from "jest-mock";
|
||||||
|
import expect from "expect";
|
||||||
|
import snapshot from "jest-snapshot";
|
||||||
|
import * as circus from "jest-circus";
|
||||||
|
|
||||||
|
expect.extend({
|
||||||
|
toMatchInlineSnapshot: snapshot.toMatchInlineSnapshot,
|
||||||
|
toMatchSnapshot: snapshot.toMatchSnapshot,
|
||||||
|
toThrowErrorMatchingInlineSnapshot:
|
||||||
|
snapshot.toThrowErrorMatchingInlineSnapshot,
|
||||||
|
toThrowErrorMatchingSnapshot: snapshot.toThrowErrorMatchingSnapshot,
|
||||||
|
});
|
||||||
|
|
||||||
|
globalThis.expect = expect;
|
||||||
|
globalThis.test = circus.test;
|
||||||
|
globalThis.it = circus.it;
|
||||||
|
globalThis.describe = circus.describe;
|
||||||
|
globalThis.beforeAll = circus.beforeAll;
|
||||||
|
globalThis.afterAll = circus.afterAll;
|
||||||
|
globalThis.beforeEach = circus.beforeEach;
|
||||||
|
globalThis.afterEach = circus.afterEach;
|
||||||
|
globalThis.jest = {
|
||||||
|
fn: mock.fn,
|
||||||
|
spyOn: mock.spyOn,
|
||||||
|
};
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { Piscina } from "piscina";
|
||||||
|
import supportsColor from "supports-color";
|
||||||
|
import { MessageChannel } from "worker_threads";
|
||||||
|
import os from "os";
|
||||||
|
|
||||||
|
/** @typedef {import("@jest/test-result").Test} Test */
|
||||||
|
|
||||||
|
const piscina = new Piscina({
|
||||||
|
filename: new URL("./worker-runner.js", import.meta.url).href,
|
||||||
|
maxThreads: os.cpus().length / 2,
|
||||||
|
env: {
|
||||||
|
// Workers don't have a tty; we whant them to inherit
|
||||||
|
// the color support level from the main thread.
|
||||||
|
FORCE_COLOR: supportsColor.stdout.level,
|
||||||
|
...process.env,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default class LightRunner {
|
||||||
|
#config;
|
||||||
|
|
||||||
|
constructor(config) {
|
||||||
|
this.#config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<Test>} tests
|
||||||
|
* @param {*} watcher
|
||||||
|
* @param {*} onStart
|
||||||
|
* @param {*} onResult
|
||||||
|
* @param {*} onFailure
|
||||||
|
*/
|
||||||
|
runTests(tests, watcher, onStart, onResult, onFailure) {
|
||||||
|
const { updateSnapshot } = this.#config;
|
||||||
|
|
||||||
|
return Promise.all(
|
||||||
|
tests.map((test) => {
|
||||||
|
const mc = new MessageChannel();
|
||||||
|
mc.port2.onmessage = () => onStart(test);
|
||||||
|
mc.port2.unref();
|
||||||
|
|
||||||
|
return piscina
|
||||||
|
.run(
|
||||||
|
{ test, updateSnapshot, port: mc.port1 },
|
||||||
|
{ transferList: [mc.port1] }
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
(result) => void onResult(test, result),
|
||||||
|
(error) => void onFailure(test, error)
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,235 @@
|
|||||||
|
import path from "path";
|
||||||
|
import { fileURLToPath, pathToFileURL } from "url";
|
||||||
|
import { performance } from "perf_hooks";
|
||||||
|
import snapshot from "jest-snapshot";
|
||||||
|
import expect from "expect";
|
||||||
|
import * as circus from "jest-circus";
|
||||||
|
|
||||||
|
import "./global-setup.js";
|
||||||
|
|
||||||
|
/** @typedef {{ failures: number, passses: number, pending: number, start: number, end: number }} Stats */
|
||||||
|
/** @typedef {{ ancestors: string[], title: string, errors: Error[], skipped: boolean }} InternalTestResult */
|
||||||
|
|
||||||
|
// Node.js workers (worker_therads) don't support
|
||||||
|
// process.chdir, that we use multiple times in our tests.
|
||||||
|
// We can "polyfill" it for process.cwd() usage, but it
|
||||||
|
// won't affect path.* and fs.* functions.
|
||||||
|
{
|
||||||
|
const startCwd = process.cwd();
|
||||||
|
let cwd = startCwd;
|
||||||
|
process.cwd = () => cwd;
|
||||||
|
process.chdir = dir => {
|
||||||
|
cwd = path.resolve(cwd, dir);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function ({ test, updateSnapshot, port }) {
|
||||||
|
port.postMessage("start");
|
||||||
|
|
||||||
|
const {setupFiles, snapshotSerializers} = test.context.config;
|
||||||
|
for (const path of setupFiles) {
|
||||||
|
await import(pathToFileURL(path));
|
||||||
|
}
|
||||||
|
for (const path of snapshotSerializers) {
|
||||||
|
const {default: serializer} = await import(pathToFileURL(path));
|
||||||
|
snapshot.addSerializer(serializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @type {Stats} */
|
||||||
|
const stats = { passes: 0, failures: 0, pending: 0, start: 0, end: 0 };
|
||||||
|
/** @type {Array<InternalTestResult>} */
|
||||||
|
const results = [];
|
||||||
|
|
||||||
|
const { tests, hasFocusedTests } = await loadTests(test.path);
|
||||||
|
|
||||||
|
const snapshotState = new snapshot.SnapshotState(
|
||||||
|
`${path.dirname(test.path)}/__snapshots__/${path.basename(test.path)}.snap`,
|
||||||
|
{ prettierPath: "prettier", updateSnapshot }
|
||||||
|
);
|
||||||
|
expect.setState({ snapshotState });
|
||||||
|
|
||||||
|
stats.start = performance.now();
|
||||||
|
await runTestBlock(tests, hasFocusedTests, results, stats);
|
||||||
|
stats.end = performance.now();
|
||||||
|
|
||||||
|
snapshotState._inlineSnapshots.forEach(({ frame }) => {
|
||||||
|
// When using native ESM, errors have an URL location.
|
||||||
|
// Jest expects paths.
|
||||||
|
frame.file = fileURLToPath(frame.file);
|
||||||
|
});
|
||||||
|
snapshotState.save();
|
||||||
|
|
||||||
|
return toTestResult(stats, results, test);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadTests(testFile) {
|
||||||
|
circus.resetState();
|
||||||
|
await import(pathToFileURL(testFile));
|
||||||
|
const { rootDescribeBlock, hasFocusedTests } = circus.getState();
|
||||||
|
return { tests: rootDescribeBlock, hasFocusedTests };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runTestBlock(
|
||||||
|
block,
|
||||||
|
hasFocusedTests,
|
||||||
|
results,
|
||||||
|
stats,
|
||||||
|
ancestors = []
|
||||||
|
) {
|
||||||
|
await runHooks("beforeAll", block, results, stats, ancestors);
|
||||||
|
|
||||||
|
for (const child of block.children) {
|
||||||
|
const { type, mode, fn, name } = child;
|
||||||
|
const nextAncestors = ancestors.concat(name);
|
||||||
|
|
||||||
|
if (
|
||||||
|
mode === "skip" ||
|
||||||
|
(hasFocusedTests && type === "test" && mode !== "only")
|
||||||
|
) {
|
||||||
|
stats.pending++;
|
||||||
|
results.push({ ancestors, title: name, errors: [], skipped: true });
|
||||||
|
} else if (type === "describeBlock") {
|
||||||
|
await runTestBlock(child, hasFocusedTests, results, stats, nextAncestors);
|
||||||
|
} else if (type === "test") {
|
||||||
|
await runHooks("beforeEach", block, results, stats, nextAncestors, true);
|
||||||
|
await runTest(fn, stats, results, ancestors, name);
|
||||||
|
await runHooks("afterEach", block, results, stats, nextAncestors, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await runHooks("afterAll", block, results, stats, ancestors);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Function} fn
|
||||||
|
* @param {Stats} stats
|
||||||
|
* @param {Array<InternalTestResult>} results
|
||||||
|
* @param {string[]} ancestors
|
||||||
|
* @param {string} name
|
||||||
|
*/
|
||||||
|
async function runTest(fn, stats, results, ancestors, name) {
|
||||||
|
expect.setState({
|
||||||
|
suppressedErrors: [],
|
||||||
|
currentTestName: ancestors.concat(name).join(" "),
|
||||||
|
});
|
||||||
|
|
||||||
|
const errors = [];
|
||||||
|
await callAsync(fn).catch(error => {
|
||||||
|
errors.push(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get suppressed errors from ``jest-matchers`` that weren't throw during
|
||||||
|
// test execution and add them to the test result, potentially failing
|
||||||
|
// a passing test.
|
||||||
|
const { suppressedErrors } = expect.getState();
|
||||||
|
expect.setState({ suppressedErrors: [] });
|
||||||
|
if (suppressedErrors.length > 0) {
|
||||||
|
errors.unshift(...suppressedErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.length > 0) {
|
||||||
|
stats.failures++;
|
||||||
|
} else {
|
||||||
|
stats.passes++;
|
||||||
|
}
|
||||||
|
results.push({ ancestors, title: name, errors, skipped: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runHooks(hook, block, results, stats, ancestors, runInParents) {
|
||||||
|
for (const { type, fn } of block.hooks) {
|
||||||
|
if (type === hook) {
|
||||||
|
await callAsync(fn).catch(error => {
|
||||||
|
stats.failures++;
|
||||||
|
results.push({ ancestors, title: `(${hook})`, error, skipped: false });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.parent && runInParents) {
|
||||||
|
await runHooks(hook, block.parent, results, stats, ancestors, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function callAsync(fn) {
|
||||||
|
if (fn.length >= 1) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
fn((err, result) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return Promise.resolve().then(fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {Stats} stats
|
||||||
|
* @param {Array<InternalTestResult>} tests
|
||||||
|
* @param {import("@jest/test-result").Test} testInput
|
||||||
|
* @returns {import("@jest/test-result").TestResult}
|
||||||
|
*/
|
||||||
|
function toTestResult(stats, tests, { path, context }) {
|
||||||
|
const { start, end } = stats;
|
||||||
|
const runtime = end - start;
|
||||||
|
|
||||||
|
return {
|
||||||
|
coverage: globalThis.__coverage__,
|
||||||
|
console: null,
|
||||||
|
failureMessage: tests
|
||||||
|
.filter(t => t.errors.length > 0)
|
||||||
|
.map(failureToString)
|
||||||
|
.join("\n"),
|
||||||
|
numFailingTests: stats.failures,
|
||||||
|
numPassingTests: stats.passes,
|
||||||
|
numPendingTests: stats.pending,
|
||||||
|
perfStats: {
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
runtime: Math.round(runtime), // ms precision
|
||||||
|
slow: runtime / 1000 > context.config.slowTestThreshold,
|
||||||
|
},
|
||||||
|
skipped: false,
|
||||||
|
snapshot: {
|
||||||
|
added: 0,
|
||||||
|
fileDeleted: false,
|
||||||
|
matched: 0,
|
||||||
|
unchecked: 0,
|
||||||
|
unmatched: 0,
|
||||||
|
updated: 0,
|
||||||
|
},
|
||||||
|
sourceMaps: {},
|
||||||
|
testExecError: null,
|
||||||
|
testFilePath: path,
|
||||||
|
testResults: tests.map(test => {
|
||||||
|
return {
|
||||||
|
ancestorTitles: test.ancestors,
|
||||||
|
duration: test.duration / 1000,
|
||||||
|
failureMessages: test.errors.length ? [failureToString(test)] : [],
|
||||||
|
fullName: test.title,
|
||||||
|
numPassingAsserts: test.errors.length > 0 ? 1 : 0,
|
||||||
|
status: test.skipped
|
||||||
|
? "pending"
|
||||||
|
: test.errors.length > 0
|
||||||
|
? "failed"
|
||||||
|
: "passed",
|
||||||
|
title: test.title,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function failureToString(test) {
|
||||||
|
return (
|
||||||
|
test.ancestors.concat(test.title).join(" > ") +
|
||||||
|
"\n" +
|
||||||
|
test.errors.map(e => e.toString().replace(/^/gm, "\t")).join("\n") +
|
||||||
|
"\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"main": "./index.js"
|
"main": "./index.cjs"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const createPlugin = require("../../utils/create-plugin.js");
|
const createPlugin = require("../../utils/create-plugin.cjs");
|
||||||
|
|
||||||
module.exports = createPlugin({
|
module.exports = createPlugin({
|
||||||
name: "uppercase-rocks",
|
name: "uppercase-rocks",
|
||||||
@@ -2,5 +2,5 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"name": "prettier-plugin-uppercase-rocks",
|
"name": "prettier-plugin-uppercase-rocks",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"main": "./index.js"
|
"main": "./index.cjs"
|
||||||
}
|
}
|
||||||
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,3 @@
|
|||||||
"use strict";
|
import run_spec from "./format-test.js";
|
||||||
|
|
||||||
Object.defineProperty(global, "run_spec", {
|
globalThis.run_spec = run_spec;
|
||||||
get() {
|
|
||||||
return require("./format-test.js");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
"use strict";
|
import path from "node:path";
|
||||||
|
import { outdent } from "outdent";
|
||||||
|
import createEsmUtils from "esm-utils";
|
||||||
|
|
||||||
const path = require("path");
|
const { __dirname, __filename } = createEsmUtils(import.meta);
|
||||||
const { outdent } = require("outdent");
|
|
||||||
|
|
||||||
const TESTS_ROOT = path.join(__dirname, "../../format");
|
const TESTS_ROOT = path.join(__dirname, "../../format");
|
||||||
|
|
||||||
@@ -204,4 +205,4 @@ const checkParser = ({ dirname, files }, parsers = []) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = checkParser;
|
export default checkParser;
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
function consistentEndOfLine(text) {
|
function consistentEndOfLine(text) {
|
||||||
let firstEndOfLine;
|
let firstEndOfLine;
|
||||||
return text.replace(/\r\n?|\n/g, (endOfLine) => {
|
return text.replace(/\r\n?|\n/g, (endOfLine) => {
|
||||||
@@ -10,4 +8,4 @@ function consistentEndOfLine(text) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = consistentEndOfLine;
|
export default consistentEndOfLine;
|
||||||
File renamed without changes.
@@ -1,8 +1,6 @@
|
|||||||
"use strict";
|
import { wrap as raw } from "jest-snapshot-serializer-raw";
|
||||||
|
import visualizeRange from "./visualize-range.js";
|
||||||
const raw = require("jest-snapshot-serializer-raw").wrap;
|
import visualizeEndOfLine from "./visualize-end-of-line.js";
|
||||||
const visualizeRange = require("./visualize-range.js");
|
|
||||||
const visualizeEndOfLine = require("./visualize-end-of-line.js");
|
|
||||||
|
|
||||||
const SEPARATOR_WIDTH = 80;
|
const SEPARATOR_WIDTH = 80;
|
||||||
function printSeparator(description = "") {
|
function printSeparator(description = "") {
|
||||||
@@ -95,4 +93,4 @@ function createSnapshot(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = createSnapshot;
|
export default createSnapshot;
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
function stringifyOptions(options) {
|
function stringifyOptions(options) {
|
||||||
const string = JSON.stringify(options || {}, (key, value) =>
|
const string = JSON.stringify(options || {}, (key, value) =>
|
||||||
key === "plugins" || key === "errors"
|
key === "plugins" || key === "errors"
|
||||||
@@ -12,4 +10,4 @@ function stringifyOptions(options) {
|
|||||||
return string === "{}" ? "" : string;
|
return string === "{}" ? "" : string;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = stringifyOptions;
|
export default stringifyOptions;
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
function visualizeEndOfLine(text) {
|
function visualizeEndOfLine(text) {
|
||||||
return text.replace(/\r\n?|\n/g, (endOfLine) => {
|
return text.replace(/\r\n?|\n/g, (endOfLine) => {
|
||||||
switch (endOfLine) {
|
switch (endOfLine) {
|
||||||
@@ -15,4 +13,4 @@ function visualizeEndOfLine(text) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = visualizeEndOfLine;
|
export default visualizeEndOfLine;
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
"use strict";
|
import { LinesAndColumns } from "lines-and-columns";
|
||||||
|
import { codeFrameColumns } from "@babel/code-frame";
|
||||||
const { LinesAndColumns } = require("lines-and-columns");
|
|
||||||
const { codeFrameColumns } = require("@babel/code-frame");
|
|
||||||
const codeFrameColumnsOptions = {
|
const codeFrameColumnsOptions = {
|
||||||
linesAbove: Number.POSITIVE_INFINITY,
|
linesAbove: Number.POSITIVE_INFINITY,
|
||||||
linesBelow: Number.POSITIVE_INFINITY,
|
linesBelow: Number.POSITIVE_INFINITY,
|
||||||
@@ -37,4 +35,4 @@ const visualizeRange = (text, { rangeStart = 0, rangeEnd = text.length }) =>
|
|||||||
: codeFrameColumnsOptions
|
: codeFrameColumnsOptions
|
||||||
);
|
);
|
||||||
|
|
||||||
module.exports = visualizeRange;
|
export default visualizeRange;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
run_spec(__dirname, ["angular"], { trailingComma: "none" });
|
run_spec(import.meta, ["angular"], { trailingComma: "none" });
|
||||||
run_spec(__dirname, ["angular"]);
|
run_spec(import.meta, ["angular"]);
|
||||||
run_spec(__dirname, ["angular"], { printWidth: 1 });
|
run_spec(import.meta, ["angular"], { printWidth: 1 });
|
||||||
run_spec(__dirname, ["angular"], { htmlWhitespaceSensitivity: "ignore" });
|
run_spec(import.meta, ["angular"], { htmlWhitespaceSensitivity: "ignore" });
|
||||||
run_spec(__dirname, ["angular"], { bracketSpacing: false });
|
run_spec(import.meta, ["angular"], { bracketSpacing: false });
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
run_spec(__dirname, ["angular"], { bracketSameLine: true });
|
run_spec(import.meta, ["angular"], { bracketSameLine: true });
|
||||||
run_spec(__dirname, ["angular"], { bracketSameLine: false });
|
run_spec(import.meta, ["angular"], { bracketSameLine: false });
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
// We always pass {trailingComma: "none"} when printing
|
// We always pass {trailingComma: "none"} when printing
|
||||||
run_spec(__dirname, ["__ng_interpolation"], { trailingComma: "none" });
|
run_spec(import.meta, ["__ng_interpolation"], { trailingComma: "none" });
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["angular"]);
|
run_spec(import.meta, ["angular"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
run_spec(__dirname, ["css"], { singleQuote: true });
|
run_spec(import.meta, ["css"], { singleQuote: true });
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css", "scss", "less"]);
|
run_spec(import.meta, ["css", "scss", "less"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
run_spec(__dirname, ["css"], { singleQuote: true });
|
run_spec(import.meta, ["css"], { singleQuote: true });
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["css"]);
|
run_spec(import.meta, ["css"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
@@ -1 +1 @@
|
|||||||
run_spec(__dirname, ["flow"]);
|
run_spec(import.meta, ["flow"]);
|
||||||
Loaded 100 of 1161 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user