sort-imports: ESLint Suppression Comments (#51881)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51881

Switches the suppression of ESLint for the generated `sort-imports` lint rule definition to using in-file comments instead of `.eslintignore`.

This makes the suppression more portable. If the path to the lint rule definition changes, we don't have to remember to update `.eslintignore`.

Changelog:
[Internal]

Reviewed By: SamChou19815

Differential Revision: D76152973

fbshipit-source-id: 7cc41282931788c9e347712e7ce8bf7fefb53858
This commit is contained in:
Tim Yung authored and Facebook GitHub Bot committed 2025-06-09 20:30:32 -07:00
1 parent ad652cf99c
commit fb7a45a934
3 files changed
+5 -2

No files matched your search

-1
View File
@@ -13,7 +13,6 @@ packages/*/dist
packages/*/types_generated
packages/debugger-frontend/dist/**/*
packages/react-native-codegen/lib
tools/eslint/rules/sort-imports.js
**/Pods/*
**/*.macos.js
**/*.windows.js
+1
View File
@@ -28,6 +28,7 @@ module.exports = {
files: ['*.js', '*.js.flow', '*.jsx'],
parser: 'hermes-eslint',
rules: {
'eslint-comments/no-unlimited-disable': 0,
'ft-flow/require-valid-file-annotation': [2, 'always'],
'no-extra-boolean-cast': 0,
'no-void': 0,
+4 -1
View File
@@ -6,7 +6,10 @@
*
* To regenerate this file, please run this command on Meta's monorepo:
* @codegen-command : xplat/js/tools/sort-imports/scripts/build.sh
* @generated SignedSource<<374df066e2e1e673cc452314636d8dd8>>
* @generated SignedSource<<7b842f046d041c0d5d44b62d0f8244e1>>
* @nolint
*/
/* eslint-disable */
"use strict";var e,t,n=require("path");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}function o(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}function l(){if(t)return e;t=1;const r=n,o=__dirname.split(r.sep).includes("xplat");function i(e){if(("Literal"===e.type||"JSXText"===e.type)&&"string"==typeof e.value)return e.value;if("BinaryExpression"===e.type&&"+"===e.operator){const t=i(e.left),n=i(e.right);if(null!=t&&null!=n)return t+n}return null}function a(e){if("Identifier"===e.type)return e.name;if("ThisExpression"===e.type)return"this";if("MemberExpression"===e.type){const t=a(e.object),n=e.computed?i(e.property):a(e.property);if(null!=t&&null!=n)return t+"."+n}else if("TypeCastExpression"===e.type||"AsExpression"===e.type)return a(e.expression);return null}function l(e){return e.callee?a(e.callee):null}function s(e,t,n){const r=e.getSourceCode().getText(),o=function(e,t){if(t.line<1)throw new RangeError("Line number "+t.line+" is before the start of file");const n=/\r\n|\r|\n|\u2028|\u2029/g;let r={index:0};for(let o=1;o<t.line;++o)if(r=n.exec(e),null==r)throw new RangeError("Line number "+t.line+" is past the end of file");if(null==r)throw new RangeError("Line number "+t.line+" is past the end of file");return r.index+(r[0]||"").length}(r,t)+t.column+n;return function(e,t){if(t<0)throw new RangeError("computed offset "+t+" is a negative index");if(t>=e.length)throw new RangeError("computed offset "+t+" is past the end of file");const n=/\r\n|\r|\n|\u2028|\u2029/g;let r,o={index:0},i=0;do{r=o,o=n.exec(e),++i}while(o&&o.index<t);return{line:i,column:t-r.index-(r[0]||"").length}}(r,o)}function u(e,t){let n;return e.variables.some((function(e){return!(!e.defs.length||e.name!==t)&&(n=e,!0)})),n||(null==e.upper?null:u(e.upper,t))}const c=e=>"string"==typeof e&&e.charCodeAt(0)>=97,p=e=>"string"==typeof e&&e.charCodeAt(0)<=90;function f(e){return null!=e&&"VariableDeclaration"===e.type&&"Program"===e.parent.type&&1===e.declarations.length&&null!=e.declarations[0].init&&d(e.declarations[0].init)}function m(e){return null!=e&&"VariableDeclarator"===e.type&&"VariableDeclaration"===e.parent.type&&"Program"===e.parent.parent.type&&1===e.parent.declarations.length&&d(e.init)}function d(e){return null!=e&&(y(e)||h(e)||x(e))}function g(e){return null!=e&&"CallExpression"===e.type&&e.callee&&"Identifier"===e.callee.type&&"requireNUX"===e.callee.name&&2===e.arguments.length&&"Literal"===e.arguments[0].type}function y(e){return"CallExpression"===e.type&&e.callee&&"Identifier"===e.callee.type&&"require"===e.callee.name&&1===e.arguments.length&&"Literal"===e.arguments[0].type}function h(e){return"CallExpression"===e.type&&"Identifier"===e.callee.type&&"requireDeferred"===e.callee.name&&1===e.arguments.length&&"Literal"===e.arguments[0].type&&"string"==typeof e.arguments[0].value}function x(e){return"CallExpression"===e.type&&"Identifier"===e.callee.type&&"requireDeferredForDisplay"===e.callee.name&&1===e.arguments.length&&"Literal"===e.arguments[0].type&&"string"==typeof e.arguments[0].value}function b(e){return"ImportDeclaration"===e.type&&(null==e.importKind||"value"===e.importKind)}function C(e){return"ImportDeclaration"===e.type&&("type"===e.importKind||"typeof"===e.importKind)}function S(e){return b(e)||C(e)}function v(e){return null!=e&&"CallExpression"===e.type&&e.callee&&"Identifier"===e.callee.type&&"JSResource"===e.callee.name&&1===e.arguments.length&&"Literal"===e.arguments[0].type}function E(e){return null!=e&&"CallExpression"===e.type&&e.callee&&"Identifier"===e.callee.type&&"JSResourceForInteraction"===e.callee.name&&2===e.arguments.length&&"Literal"===e.arguments[0].type}function I(e){return null!=e&&"CallExpression"===e.type&&"Identifier"===e.callee.type&&"ClientJSResource"===e.callee.name&&1===e.arguments.length&&"Literal"===e.arguments[0].type&&"string"==typeof e.arguments[0].value}function D(e){if(null==e||"CallExpression"!==e.type||null==e.callee)return!1;let t;return"IdentifierLine truncated