From ea9597cd73d1af016ac515df050b6d855249b9d8 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Mon, 25 Mar 2024 23:34:47 +0300 Subject: [PATCH 01/17] Added option to allow comments --- docs/rules/no-empty-file.md | 23 +++++++++++++++++++++++ rules/no-empty-file.js | 12 ++++++++++++ test/no-empty-file.mjs | 16 ++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/docs/rules/no-empty-file.md b/docs/rules/no-empty-file.md index 72244e26d4..6346158146 100644 --- a/docs/rules/no-empty-file.md +++ b/docs/rules/no-empty-file.md @@ -68,3 +68,26 @@ const x = 0; const x = 0; } ``` + +## Options + +### allow + +Type: `Array`\ +Default: `[]` + +You can set the `allow` option like this: + +```js +"unicorn/no-empty-file": { + "allow": [ + "comments" + ] +} +``` + +If you set it to `comments`, you can only store files with comments + +```js +// Comment +``` diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index dc3a396917..2da0bdd732 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -15,9 +15,17 @@ const isTripleSlashDirective = node => const hasTripeSlashDirectives = comments => comments.some(currentNode => isTripleSlashDirective(currentNode)); +const isProgramFileEmpty = node => node.type === 'Program' && node.body.length === 0; + +const isAllowOnlyCommentsFile = (option, node) => option.allow.includes('comments') && isProgramFileEmpty(node); + /** @param {import('eslint').Rule.RuleContext} context */ const create = context => { const filename = context.physicalFilename; + const options = { + allow: [], + ...context.options[0] + } if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) { return; @@ -36,6 +44,10 @@ const create = context => { return; } + if (isAllowOnlyCommentsFile(options, node)) { + return; + } + return { node, messageId: MESSAGE_ID, diff --git a/test/no-empty-file.mjs b/test/no-empty-file.mjs index 2d28d85749..2420278b2b 100644 --- a/test/no-empty-file.mjs +++ b/test/no-empty-file.mjs @@ -30,6 +30,22 @@ test.snapshot({ '[]', '(() => {})()', ].map(code => ({code, filename: 'example.js'})), + ...[ + '// comment', + '/* comment */', + '/// comment', + outdent` + /* + comment + */ + `, + outdent` + /* + comment + */ + console.log('done'); + `, + ].map(code => ({code, filename: 'example.js', options: [{ allow: ['comments'] }]})), '', ...[ 'md', From b6a73035be339b30ab78cd29820924cd74080247 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Tue, 26 Mar 2024 21:30:19 +0300 Subject: [PATCH 02/17] Fix issue with lint --- rules/no-empty-file.js | 4 ++-- test/no-empty-file.mjs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index 2da0bdd732..3352541fd6 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -24,8 +24,8 @@ const create = context => { const filename = context.physicalFilename; const options = { allow: [], - ...context.options[0] - } + ...context.options[0], + }; if (!/\.(?:js|mjs|cjs|jsx|ts|mts|cts|tsx)$/i.test(filename)) { return; diff --git a/test/no-empty-file.mjs b/test/no-empty-file.mjs index 2420278b2b..7e67f3f5ce 100644 --- a/test/no-empty-file.mjs +++ b/test/no-empty-file.mjs @@ -35,17 +35,17 @@ test.snapshot({ '/* comment */', '/// comment', outdent` - /* - comment - */ + /* + comment + */ `, outdent` - /* - comment - */ - console.log('done'); + /* + comment + */ + console.log('done'); `, - ].map(code => ({code, filename: 'example.js', options: [{ allow: ['comments'] }]})), + ].map(code => ({code, filename: 'example.js', options: [{allow: ['comments']}]})), '', ...[ 'md', From feddfb52da04e80d85c194ca36f4580c8fdd9d2c Mon Sep 17 00:00:00 2001 From: grshakirova Date: Tue, 26 Mar 2024 21:33:07 +0300 Subject: [PATCH 03/17] Fix issue with lint --- docs/rules/consistent-destructuring.md | 2 +- docs/rules/explicit-length-check.md | 2 +- docs/rules/no-anonymous-default-export.md | 2 +- docs/rules/no-array-callback-reference.md | 2 +- docs/rules/no-array-for-each.md | 2 +- docs/rules/no-array-method-this-argument.md | 2 +- docs/rules/no-array-push-push.md | 2 +- docs/rules/no-await-in-promise-methods.md | 2 +- docs/rules/no-for-loop.md | 2 +- docs/rules/no-new-array.md | 2 +- docs/rules/no-new-buffer.md | 2 +- docs/rules/no-null.md | 2 +- docs/rules/no-single-promise-in-promise-methods.md | 2 +- docs/rules/no-typeof-undefined.md | 2 +- docs/rules/no-useless-switch-case.md | 2 +- docs/rules/prefer-array-find.md | 2 +- docs/rules/prefer-array-index-of.md | 2 +- docs/rules/prefer-array-some.md | 2 +- docs/rules/prefer-at.md | 2 +- docs/rules/prefer-code-point.md | 2 +- docs/rules/prefer-default-parameters.md | 2 +- docs/rules/prefer-dom-node-remove.md | 2 +- docs/rules/prefer-dom-node-text-content.md | 2 +- docs/rules/prefer-export-from.md | 2 +- docs/rules/prefer-includes.md | 2 +- docs/rules/prefer-logical-operator-over-ternary.md | 2 +- docs/rules/prefer-math-trunc.md | 2 +- docs/rules/prefer-module.md | 2 +- docs/rules/prefer-number-properties.md | 2 +- docs/rules/prefer-regexp-test.md | 2 +- docs/rules/prefer-set-has.md | 2 +- docs/rules/prefer-spread.md | 2 +- docs/rules/prefer-string-starts-ends-with.md | 2 +- docs/rules/prefer-top-level-await.md | 2 +- docs/rules/relative-url-style.md | 2 +- docs/rules/require-post-message-target-origin.md | 2 +- docs/rules/string-content.md | 2 +- docs/rules/text-encoding-identifier-case.md | 2 +- readme.md | 2 +- 39 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/rules/consistent-destructuring.md b/docs/rules/consistent-destructuring.md index 235671e0ce..bdc6cd708e 100644 --- a/docs/rules/consistent-destructuring.md +++ b/docs/rules/consistent-destructuring.md @@ -2,7 +2,7 @@ 🚫 This rule is _disabled_ in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/explicit-length-check.md b/docs/rules/explicit-length-check.md index f9842df00e..decb245355 100644 --- a/docs/rules/explicit-length-check.md +++ b/docs/rules/explicit-length-check.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-anonymous-default-export.md b/docs/rules/no-anonymous-default-export.md index 8ac3c117fe..8525b946c5 100644 --- a/docs/rules/no-anonymous-default-export.md +++ b/docs/rules/no-anonymous-default-export.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-array-callback-reference.md b/docs/rules/no-array-callback-reference.md index 7e4a71ca72..035c698225 100644 --- a/docs/rules/no-array-callback-reference.md +++ b/docs/rules/no-array-callback-reference.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-array-for-each.md b/docs/rules/no-array-for-each.md index 9e9064208d..0a0821006b 100644 --- a/docs/rules/no-array-for-each.md +++ b/docs/rules/no-array-for-each.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-array-method-this-argument.md b/docs/rules/no-array-method-this-argument.md index e6ffdd0b72..8dea99564a 100644 --- a/docs/rules/no-array-method-this-argument.md +++ b/docs/rules/no-array-method-this-argument.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-array-push-push.md b/docs/rules/no-array-push-push.md index d3b924b609..914fe9f87e 100644 --- a/docs/rules/no-array-push-push.md +++ b/docs/rules/no-array-push-push.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-await-in-promise-methods.md b/docs/rules/no-await-in-promise-methods.md index 1da102aa98..e42e16d55d 100644 --- a/docs/rules/no-await-in-promise-methods.md +++ b/docs/rules/no-await-in-promise-methods.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-for-loop.md b/docs/rules/no-for-loop.md index 696803ba53..4b6d3d5cac 100644 --- a/docs/rules/no-for-loop.md +++ b/docs/rules/no-for-loop.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-new-array.md b/docs/rules/no-new-array.md index 0cc4171cd1..574513309c 100644 --- a/docs/rules/no-new-array.md +++ b/docs/rules/no-new-array.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-new-buffer.md b/docs/rules/no-new-buffer.md index 7cfd83d43d..982b7338ae 100644 --- a/docs/rules/no-new-buffer.md +++ b/docs/rules/no-new-buffer.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-null.md b/docs/rules/no-null.md index 214d694abc..15f5417894 100644 --- a/docs/rules/no-null.md +++ b/docs/rules/no-null.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-single-promise-in-promise-methods.md b/docs/rules/no-single-promise-in-promise-methods.md index c7fe1754d0..50cb47e4f5 100644 --- a/docs/rules/no-single-promise-in-promise-methods.md +++ b/docs/rules/no-single-promise-in-promise-methods.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-typeof-undefined.md b/docs/rules/no-typeof-undefined.md index 85dde54fe1..f48a5f84c9 100644 --- a/docs/rules/no-typeof-undefined.md +++ b/docs/rules/no-typeof-undefined.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/no-useless-switch-case.md b/docs/rules/no-useless-switch-case.md index aae2844aaa..a4fe0952e9 100644 --- a/docs/rules/no-useless-switch-case.md +++ b/docs/rules/no-useless-switch-case.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-array-find.md b/docs/rules/prefer-array-find.md index 398de47429..a36c362958 100644 --- a/docs/rules/prefer-array-find.md +++ b/docs/rules/prefer-array-find.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-array-index-of.md b/docs/rules/prefer-array-index-of.md index 539337ba63..59292b0e30 100644 --- a/docs/rules/prefer-array-index-of.md +++ b/docs/rules/prefer-array-index-of.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-array-some.md b/docs/rules/prefer-array-some.md index e99a55d059..a579540eb6 100644 --- a/docs/rules/prefer-array-some.md +++ b/docs/rules/prefer-array-some.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-at.md b/docs/rules/prefer-at.md index 6cea0ab4ae..1720004a83 100644 --- a/docs/rules/prefer-at.md +++ b/docs/rules/prefer-at.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-code-point.md b/docs/rules/prefer-code-point.md index 2e9033e0a6..3ca2de6686 100644 --- a/docs/rules/prefer-code-point.md +++ b/docs/rules/prefer-code-point.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-default-parameters.md b/docs/rules/prefer-default-parameters.md index 60080463da..e88d7a483f 100644 --- a/docs/rules/prefer-default-parameters.md +++ b/docs/rules/prefer-default-parameters.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-dom-node-remove.md b/docs/rules/prefer-dom-node-remove.md index 790904f6a3..e0373dd47a 100644 --- a/docs/rules/prefer-dom-node-remove.md +++ b/docs/rules/prefer-dom-node-remove.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-dom-node-text-content.md b/docs/rules/prefer-dom-node-text-content.md index d2b7f1b194..97755e187b 100644 --- a/docs/rules/prefer-dom-node-text-content.md +++ b/docs/rules/prefer-dom-node-text-content.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-export-from.md b/docs/rules/prefer-export-from.md index c89158fb1e..affbc9e9de 100644 --- a/docs/rules/prefer-export-from.md +++ b/docs/rules/prefer-export-from.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-includes.md b/docs/rules/prefer-includes.md index 6302e2f166..28a0b8eb9c 100644 --- a/docs/rules/prefer-includes.md +++ b/docs/rules/prefer-includes.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-logical-operator-over-ternary.md b/docs/rules/prefer-logical-operator-over-ternary.md index 9e27b686d5..4658bc5d75 100644 --- a/docs/rules/prefer-logical-operator-over-ternary.md +++ b/docs/rules/prefer-logical-operator-over-ternary.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-math-trunc.md b/docs/rules/prefer-math-trunc.md index 19779f5580..ca2b711a0d 100644 --- a/docs/rules/prefer-math-trunc.md +++ b/docs/rules/prefer-math-trunc.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-module.md b/docs/rules/prefer-module.md index ee6db53e47..b08fb6ba36 100644 --- a/docs/rules/prefer-module.md +++ b/docs/rules/prefer-module.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-number-properties.md b/docs/rules/prefer-number-properties.md index 7b1d94cdcb..ace82475e1 100644 --- a/docs/rules/prefer-number-properties.md +++ b/docs/rules/prefer-number-properties.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-regexp-test.md b/docs/rules/prefer-regexp-test.md index f012d51be9..ee714ac534 100644 --- a/docs/rules/prefer-regexp-test.md +++ b/docs/rules/prefer-regexp-test.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-set-has.md b/docs/rules/prefer-set-has.md index 51a7fd5e0d..f4a5070f13 100644 --- a/docs/rules/prefer-set-has.md +++ b/docs/rules/prefer-set-has.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-spread.md b/docs/rules/prefer-spread.md index fc10656610..2f118204b3 100644 --- a/docs/rules/prefer-spread.md +++ b/docs/rules/prefer-spread.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-string-starts-ends-with.md b/docs/rules/prefer-string-starts-ends-with.md index ed058dd727..2c41311dd9 100644 --- a/docs/rules/prefer-string-starts-ends-with.md +++ b/docs/rules/prefer-string-starts-ends-with.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/prefer-top-level-await.md b/docs/rules/prefer-top-level-await.md index 4cb68a96e6..83a0c4ca7b 100644 --- a/docs/rules/prefer-top-level-await.md +++ b/docs/rules/prefer-top-level-await.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/relative-url-style.md b/docs/rules/relative-url-style.md index 1e6f8b8340..822a6b0bee 100644 --- a/docs/rules/relative-url-style.md +++ b/docs/rules/relative-url-style.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/require-post-message-target-origin.md b/docs/rules/require-post-message-target-origin.md index 6350ca4697..c1e2645e2d 100644 --- a/docs/rules/require-post-message-target-origin.md +++ b/docs/rules/require-post-message-target-origin.md @@ -2,7 +2,7 @@ 🚫 This rule is _disabled_ in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ This rule is manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/string-content.md b/docs/rules/string-content.md index 1e00e5cf7d..3a2ea1f3e8 100644 --- a/docs/rules/string-content.md +++ b/docs/rules/string-content.md @@ -2,7 +2,7 @@ 🚫 This rule is _disabled_ in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/docs/rules/text-encoding-identifier-case.md b/docs/rules/text-encoding-identifier-case.md index 24da4d486b..f365bbb594 100644 --- a/docs/rules/text-encoding-identifier-case.md +++ b/docs/rules/text-encoding-identifier-case.md @@ -2,7 +2,7 @@ πŸ’Ό This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs). -πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). diff --git a/readme.md b/readme.md index fac04c3d34..61ce3c5dd7 100644 --- a/readme.md +++ b/readme.md @@ -106,7 +106,7 @@ If you don't use the preset, ensure you use the same `env` and `parserOptions` c πŸ’Ό [Configurations](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs) enabled in.\ βœ… Set in the `recommended` [configuration](https://github.com/sindresorhus/eslint-plugin-unicorn#preset-configs).\ πŸ”§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\ -πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions). +πŸ’‘ Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). | NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  | Description | πŸ’Ό | πŸ”§ | πŸ’‘ | | :----------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- | From e2f67556882efcd41009963d272560658717f998 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Tue, 26 Mar 2024 21:44:27 +0300 Subject: [PATCH 04/17] Fix issue with test --- test/snapshots/no-empty-file.mjs.snap | Bin 749 -> 752 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/snapshots/no-empty-file.mjs.snap b/test/snapshots/no-empty-file.mjs.snap index 9e43c5989dec2bc0e20ace7392b8d13b0761bc93..1a7294faaf9761fa17d1800d033301b16c702553 100644 GIT binary patch literal 752 zcmVtC@j+7w`pkoi6(h$2^3B z=@W202BvL$=cH2+6I#2z@A**Gs?!i%0y$ho`Bugf`1|{h63q?@*cxlDW>+GrNkpGf z%De!963z=0P!SwZgQ?Gq$!CbktHCs6XRU}b-W6Q~peyQ~Hz=Tmdx!s}tLmif8?9^J zXx+2_{5tQ4kmuzVXd1LV$006D?iird_r={2M=0@qKmjksB{GpjP@``y^I$FdG2RN) zo8k1ZsU_j-XiX18_+*e0`vD5r3+*V+G=J_2KvV(#9)b18T95kLk>zT{?eiHrBw2?t zT3=DrK@zH@8edVszNm&Qo1`WwDsvtchQDuMqelst)Y&j*ZHPD`!-kkhqPih!p_($^ zYBL#J-Vi7#!-l|llr_X^Q~~~Qf>NBMlq^6AE$o3Pz+{XP|2_(ME&M1=l0TQ;i|~yA zFCjldYbk_eHBkApz7+H3Lb(x&zpo&9j^&SGHAh$e7&cPLDzcKE5;3;q>6` zG#rj*$MLaQ;)3Z@;-cfIR}~z`>3?!Um~+kNF;?jrs@m@srK)9kb+ARD>KSeoqk{#h i8X2li7pB_IQ1$-cZ^ZS8Pw#77XSco&}p;) literal 749 zcmV&{Ffo{ zxgQ{+{2z-500000000Bs*UfIzKo9`nR0vfuZ~%cso6C?MiYpX1&R?-ngb=L&2@a)* zo)Av5Ro(h0*qb!S&54)bN?(HmkHjk=Cu=(s?;(oUji}F_o&9Ea*6Uv<9n0;W`#(!p zgqqYM=cY3>EVK8tDr=_i7=8cLrT&krUeBP$r(1>fLinuRF5F*RmjJ48DG|%)5R1HZ z`U5(B?|2ivcvm7L!|q$8a^|zQPY+CsIEGDFfQAB|N$ttV005Wp1@`Se{SGIlMSL(k z0**_;uq^k2^eSvXbKmn^52{La9-?v}#~Uc$ov8%={{ACG(?$WiQ_W;_A)*>b^ckfr zG7t#iyg&gJ#sM*y`ofrEj+mktOoO-AN+{z!)-?dCpx$|d0yNw^QhSm|h^~2~b*&q% z+xyRt^I-&eE^DAD&~)Ar z;bBKf!?)0!9!2okAR+c66mSsPQJ#7J(iMQX0##XqttZOB_mqz5D8w0pf@cby z7AZmP$r=RXMNz>xM^rG*hWZwx!b?@4>m1hnR2fUx#lT*nfO-TAhfmIoY&bQ%I|adb zaa=IY6&DVl5f^VqwJKmc&i~{@F#DSKW1>=XRCV92N>$78=%A}Y)pJ}b>W@~WYUHRo fTbZhvqw4+9#}%nsc^($m)mQ%jTN%{ki5CC>C>~*m From 05b218ebdd1f1c69d8874de3f8b1e74827c664b3 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Tue, 26 Mar 2024 22:33:58 +0300 Subject: [PATCH 05/17] Fix issue with test --- rules/no-empty-file.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index 3352541fd6..586a1ea407 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -56,6 +56,21 @@ const create = context => { }; }; +const schema = [ + { + type: 'object', + additionalProperties: false, + properties: { + allow: { + type: 'array', + items: { + type: 'string', + }, + }, + }, + }, +]; + /** @type {import('eslint').Rule.RuleModule} */ module.exports = { create, @@ -65,5 +80,6 @@ module.exports = { description: 'Disallow empty files.', }, messages, + schema, }, }; From 84819a295b4bde61db8e322d96372b31be91dac9 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Tue, 26 Mar 2024 22:36:03 +0300 Subject: [PATCH 06/17] Fix issue with test --- rules/no-empty-file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index 586a1ea407..84ebfb9f47 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -79,7 +79,7 @@ module.exports = { docs: { description: 'Disallow empty files.', }, - messages, schema, + messages, }, }; From f840f3e2e79b53d2f016a86ad041f2b979b891e2 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Thu, 28 Mar 2024 12:54:19 +0300 Subject: [PATCH 07/17] Fix issue with snapshot --- test/snapshots/no-empty-file.mjs.snap | Bin 752 -> 749 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/snapshots/no-empty-file.mjs.snap b/test/snapshots/no-empty-file.mjs.snap index 1a7294faaf9761fa17d1800d033301b16c702553..9e43c5989dec2bc0e20ace7392b8d13b0761bc93 100644 GIT binary patch literal 749 zcmV&{Ffo{ zxgQ{+{2z-500000000Bs*UfIzKo9`nR0vfuZ~%cso6C?MiYpX1&R?-ngb=L&2@a)* zo)Av5Ro(h0*qb!S&54)bN?(HmkHjk=Cu=(s?;(oUji}F_o&9Ea*6Uv<9n0;W`#(!p zgqqYM=cY3>EVK8tDr=_i7=8cLrT&krUeBP$r(1>fLinuRF5F*RmjJ48DG|%)5R1HZ z`U5(B?|2ivcvm7L!|q$8a^|zQPY+CsIEGDFfQAB|N$ttV005Wp1@`Se{SGIlMSL(k z0**_;uq^k2^eSvXbKmn^52{La9-?v}#~Uc$ov8%={{ACG(?$WiQ_W;_A)*>b^ckfr zG7t#iyg&gJ#sM*y`ofrEj+mktOoO-AN+{z!)-?dCpx$|d0yNw^QhSm|h^~2~b*&q% z+xyRt^I-&eE^DAD&~)Ar z;bBKf!?)0!9!2okAR+c66mSsPQJ#7J(iMQX0##XqttZOB_mqz5D8w0pf@cby z7AZmP$r=RXMNz>xM^rG*hWZwx!b?@4>m1hnR2fUx#lT*nfO-TAhfmIoY&bQ%I|adb zaa=IY6&DVl5f^VqwJKmc&i~{@F#DSKW1>=XRCV92N>$78=%A}Y)pJ}b>W@~WYUHRo fTbZhvqw4+9#}%nsc^($m)mQ%jTN%{ki5CC>C>~*m literal 752 zcmVtC@j+7w`pkoi6(h$2^3B z=@W202BvL$=cH2+6I#2z@A**Gs?!i%0y$ho`Bugf`1|{h63q?@*cxlDW>+GrNkpGf z%De!963z=0P!SwZgQ?Gq$!CbktHCs6XRU}b-W6Q~peyQ~Hz=Tmdx!s}tLmif8?9^J zXx+2_{5tQ4kmuzVXd1LV$006D?iird_r={2M=0@qKmjksB{GpjP@``y^I$FdG2RN) zo8k1ZsU_j-XiX18_+*e0`vD5r3+*V+G=J_2KvV(#9)b18T95kLk>zT{?eiHrBw2?t zT3=DrK@zH@8edVszNm&Qo1`WwDsvtchQDuMqelst)Y&j*ZHPD`!-kkhqPih!p_($^ zYBL#J-Vi7#!-l|llr_X^Q~~~Qf>NBMlq^6AE$o3Pz+{XP|2_(ME&M1=l0TQ;i|~yA zFCjldYbk_eHBkApz7+H3Lb(x&zpo&9j^&SGHAh$e7&cPLDzcKE5;3;q>6` zG#rj*$MLaQ;)3Z@;-cfIR}~z`>3?!Um~+kNF;?jrs@m@srK)9kb+ARD>KSeoqk{#h i8X2li7pB_IQ1$-cZ^ZS8Pw#77XSco&}p;) From 2cb0ecd1664a824658b77e2b92a5521acee912e8 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Fri, 10 May 2024 20:07:48 +0300 Subject: [PATCH 08/17] Fix after review --- rules/no-empty-file.js | 7 +++---- test/no-empty-file.mjs | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index ccfbf491f0..1792bfa9e8 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -14,9 +14,7 @@ const isTripleSlashDirective = node => const hasTripeSlashDirectives = comments => comments.some(currentNode => isTripleSlashDirective(currentNode)); -const isProgramFileEmpty = node => node.type === 'Program' && node.body.length === 0; - -const isAllowOnlyCommentsFile = (option, node) => option.allow.includes('comments') && isProgramFileEmpty(node); +const isAllowComments = (option) => option.allow.includes('comments'); /** @param {import('eslint').Rule.RuleContext} context */ const create = context => { @@ -38,12 +36,13 @@ const create = context => { const {sourceCode} = context; const comments = sourceCode.getAllComments(); + const hasComments = comments.length !== 0; if (hasTripeSlashDirectives(comments)) { return; } - if (isAllowOnlyCommentsFile(options, node)) { + if (isAllowComments(options) && hasComments) { return; } diff --git a/test/no-empty-file.mjs b/test/no-empty-file.mjs index 7e67f3f5ce..87cebd39f3 100644 --- a/test/no-empty-file.mjs +++ b/test/no-empty-file.mjs @@ -34,6 +34,7 @@ test.snapshot({ '// comment', '/* comment */', '/// comment', + '/* comment */ {}', outdent` /* comment From 068db208b16cb3a914bdc422758955171cee3798 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Fri, 10 May 2024 20:12:57 +0300 Subject: [PATCH 09/17] Fix lint --- rules/no-empty-file.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index 1792bfa9e8..dbe4fcd2ab 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -14,7 +14,7 @@ const isTripleSlashDirective = node => const hasTripeSlashDirectives = comments => comments.some(currentNode => isTripleSlashDirective(currentNode)); -const isAllowComments = (option) => option.allow.includes('comments'); +const isAllowComments = option => option.allow.includes('comments'); /** @param {import('eslint').Rule.RuleContext} context */ const create = context => { @@ -36,7 +36,7 @@ const create = context => { const {sourceCode} = context; const comments = sourceCode.getAllComments(); - const hasComments = comments.length !== 0; + const hasComments = comments.length > 0; if (hasTripeSlashDirectives(comments)) { return; From 063d1fb7c649870f0770965a4cc2bfb24bd1aa64 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 14 May 2024 09:19:08 +0800 Subject: [PATCH 10/17] Inline code --- rules/no-empty-file.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index dbe4fcd2ab..64c94f505a 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -14,8 +14,6 @@ const isTripleSlashDirective = node => const hasTripeSlashDirectives = comments => comments.some(currentNode => isTripleSlashDirective(currentNode)); -const isAllowComments = option => option.allow.includes('comments'); - /** @param {import('eslint').Rule.RuleContext} context */ const create = context => { const filename = context.physicalFilename; @@ -36,13 +34,12 @@ const create = context => { const {sourceCode} = context; const comments = sourceCode.getAllComments(); - const hasComments = comments.length > 0; if (hasTripeSlashDirectives(comments)) { return; } - if (isAllowComments(options) && hasComments) { + if (option.allow.includes('comments') && comments.length > 0) { return; } From 3f5215325956573033b7dac559b6a3a622589ebd Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Tue, 14 May 2024 09:21:09 +0800 Subject: [PATCH 11/17] Typo --- rules/no-empty-file.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/no-empty-file.js b/rules/no-empty-file.js index 64c94f505a..140bb0a2e1 100644 --- a/rules/no-empty-file.js +++ b/rules/no-empty-file.js @@ -39,7 +39,7 @@ const create = context => { return; } - if (option.allow.includes('comments') && comments.length > 0) { + if (options.allow.includes('comments') && comments.length > 0) { return; } From b53dd043cd1b06a8b4fb447c8fead4addbb4d86f Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 14 May 2024 18:29:45 +0700 Subject: [PATCH 12/17] Update no-empty-file.md --- docs/rules/no-empty-file.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/no-empty-file.md b/docs/rules/no-empty-file.md index 98bd5bad60..6f09b75aec 100644 --- a/docs/rules/no-empty-file.md +++ b/docs/rules/no-empty-file.md @@ -73,7 +73,7 @@ const x = 0; ### allow -Type: `Array`\ +Type: `string[]`\ Default: `[]` You can set the `allow` option like this: From f4fc1803ceebef72ea852668e0fa45c0d4cb9dd7 Mon Sep 17 00:00:00 2001 From: grshakirova Date: Wed, 29 May 2024 18:25:08 +0300 Subject: [PATCH 13/17] Fix allowComments --- .idea/inspectionProfiles/Project_Default.xml | 7 + .../shelved.patch | 727 ++++++++++++++++++ ..._Update_at_29_05_2024__18_08__Changes_.xml | 4 + .idea/vcs.xml | 6 + .idea/workspace.xml | 685 +++++++++++++++++ docs/rules/no-empty-file.md | 10 +- rules/no-empty-file.js | 11 +- test/no-empty-file.mjs | 2 +- 8 files changed, 1438 insertions(+), 14 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/shelf/Uncommitted_changes_before_Update_at_29_05_2024,_18_08_[Changes]/shelved.patch create mode 100644 .idea/shelf/Uncommitted_changes_before_Update_at_29_05_2024__18_08__Changes_.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000..9c69411050 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_29_05_2024,_18_08_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_29_05_2024,_18_08_[Changes]/shelved.patch new file mode 100644 index 0000000000..86b9cd432d --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_29_05_2024,_18_08_[Changes]/shelved.patch @@ -0,0 +1,727 @@ +Index: .idea/vcs.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/vcs.xml b/.idea/vcs.xml +new file mode 100644 +--- /dev/null (date 1715282478177) ++++ b/.idea/vcs.xml (date 1715282478177) +@@ -0,0 +1,6 @@ ++ ++ ++ ++ ++ ++ +\ No newline at end of file +Index: .idea/inspectionProfiles/Project_Default.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml +new file mode 100644 +--- /dev/null (date 1715282478157) ++++ b/.idea/inspectionProfiles/Project_Default.xml (date 1715282478157) +@@ -0,0 +1,7 @@ ++ ++ ++ ++ +\ No newline at end of file +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/.idea/workspace.xml b/.idea/workspace.xml +new file mode 100644 +--- /dev/null (date 1716995301744) ++++ b/.idea/workspace.xml (date 1716995301744) +@@ -0,0 +1,681 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++