Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
lib/rules/__tests__/*
test files to migrate to ESM (#7024)
This change is performed by the following script (though it requires a bit of manual). ```shell node to-esm.mjs lib/rules/*/__tests__/index.js ``` ```js // to-esm.mjs import { argv, stdout } from 'node:process'; import { readFile, unlink, writeFile } from 'node:fs/promises'; import { execSync } from 'node:child_process'; async function processFile(file) { const ruleFile = file.replace('/__tests__/index.js', '/index.js'); if ((await readFile(ruleFile, 'utf8')).includes('\tdeprecated: true,')) { stdout.write(`Skip deprecated ${file}\n`); return; } let lines = (await readFile(file, 'utf8')).split('\n'); lines = lines.filter((line) => !line.includes('use strict')); lines.forEach((line, i) => { line = line.replace( "const stripIndent = require('common-tags').stripIndent", "const { stripIndent } = require('common-tags')", ); line = line.replace( "const { messages, ruleName } = require('..');", "import rule from '../index.js'; const { messages, ruleName } = rule;", ); line = line.replace(/const (.+) = require\('(\..+)'\)/, 'import $1 from "$2.js"'); line = line.replace(/const (.+) = require\('(.+)'\)/, 'import $1 from "$2"'); lines[i] = line; }); const newFile = file.replace(/\.js$/, '.mjs'); const newContent = `${lines.join('\n')}\n`; await writeFile(newFile, newContent); stdout.write(`=> ${newFile}\n`); await unlink(file); } const files = argv.slice(2); Promise.all(files.map((f) => processFile(f))).then(() => { execSync(`npx prettier --loglevel silent --write lib/rules`, { encoding: 'utf8' }); }); ```
- Loading branch information
1 parent
366e0d8
commit b919a0b
Showing
125 changed files
with
289 additions
and
413 deletions.
There are no files selected for viewing
7 changes: 3 additions & 4 deletions
7
...s/alpha-value-notation/__tests__/index.js → .../alpha-value-notation/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
.../annotation-no-unknown/__tests__/index.js → ...annotation-no-unknown/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...s/at-rule-allowed-list/__tests__/index.js → .../at-rule-allowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...t-rule-disallowed-list/__tests__/index.js → ...-rule-disallowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...rule-empty-line-before/__tests__/index.js → ...ule-empty-line-before/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...les/at-rule-no-unknown/__tests__/index.js → ...es/at-rule-no-unknown/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...-rule-no-vendor-prefix/__tests__/index.js → ...rule-no-vendor-prefix/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...property-required-list/__tests__/index.js → ...roperty-required-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
lib/rules/block-no-empty/__tests__/index.js → lib/rules/block-no-empty/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...olor-function-notation/__tests__/index.js → ...lor-function-notation/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
lib/rules/color-hex-alpha/__tests__/index.js → ...rules/color-hex-alpha/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
...rules/color-hex-length/__tests__/index.js → ...ules/color-hex-length/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
lib/rules/color-named/__tests__/index.js → lib/rules/color-named/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
lib/rules/color-no-hex/__tests__/index.js → lib/rules/color-no-hex/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...s/color-no-invalid-hex/__tests__/index.js → .../color-no-invalid-hex/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...ment-empty-line-before/__tests__/index.js → ...ent-empty-line-before/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...rules/comment-no-empty/__tests__/index.js → ...ules/comment-no-empty/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
lib/rules/comment-pattern/__tests__/index.js → ...rules/comment-pattern/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ment-whitespace-inside/__tests__/index.js → ...ent-whitespace-inside/__tests__/index.mjs
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...t-word-disallowed-list/__tests__/index.js → ...-word-disallowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...s/custom-media-pattern/__tests__/index.js → .../custom-media-pattern/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...erty-empty-line-before/__tests__/index.js → ...rty-empty-line-before/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...o-missing-var-function/__tests__/index.js → ...-missing-var-function/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ustom-property-pattern/__tests__/index.js → ...stom-property-pattern/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...cate-custom-properties/__tests__/index.js → ...ate-custom-properties/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...o-duplicate-properties/__tests__/index.js → ...-duplicate-properties/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...nt-longhand-properties/__tests__/index.js → ...t-longhand-properties/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...and-property-overrides/__tests__/index.js → ...nd-property-overrides/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...-line-max-declarations/__tests__/index.js → ...line-max-declarations/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...tion-empty-line-before/__tests__/index.js → ...ion-empty-line-before/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...claration-no-important/__tests__/index.js → ...laration-no-important/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...on-property-max-values/__tests__/index.js → ...n-property-max-values/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...erty-unit-allowed-list/__tests__/index.js → ...rty-unit-allowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...y-unit-disallowed-list/__tests__/index.js → ...-unit-disallowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...rty-value-allowed-list/__tests__/index.js → ...ty-value-allowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...-value-disallowed-list/__tests__/index.js → ...value-disallowed-list/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...perty-value-no-unknown/__tests__/index.js → ...erty-value-no-unknown/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ont-family-name-quotes/__tests__/index.js → ...nt-family-name-quotes/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ily-no-duplicate-names/__tests__/index.js → ...ly-no-duplicate-names/__tests__/index.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.