{"id":338013,"date":"2022-09-06T15:01:30","date_gmt":"2022-09-06T15:01:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=338013"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=338013","title":{"rendered":"<span>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0434\u043b\u044f ESLint<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u044b \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0433\u0443\u0433\u043b\u0435, \u0438 \u0447\u0435\u0440\u0435\u0437 \u0447\u0430\u0441-\u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0431\u044b\u043b\u043e \u0433\u043e\u0442\u043e\u0432\u043e. \u0414\u0435\u043b\u0438\u043c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/fea\/c10\/ea9\/feac10ea929308af1307e81e37353309.jpg\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fea\/c10\/ea9\/feac10ea929308af1307e81e37353309.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e. \u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u2014 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/astexplorer.net\">AST Explorer<\/a>.<\/p>\n<p><strong>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0437\u044b\u043a<\/strong> \u2014 JavaScript.<br \/><strong>\u041f\u0430\u0440\u0441\u0435\u0440<\/strong> \u2014 babel-eslint9<br \/><strong>\u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440<\/strong> \u2014 ESLint v4 (\u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0432\u0435\u0436\u0435\u0435, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438 \u0432\u0435\u0440\u0441\u0438\u0438 4)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fc8\/c7e\/e34\/fc8c7ee34ad9073982e7d9b81768b9d5.png\" width=\"960\" height=\"470\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fc8\/c7e\/e34\/fc8c7ee34ad9073982e7d9b81768b9d5.png\"\/><figcaption><\/figcaption><\/figure>\n<ul>\n<li>\n<p>\u0412 \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e7a\/796\/b2e\/e7a796b2ef0383c834b49bd80b9e2cd8.png\" width=\"1919\" height=\"923\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e7a\/796\/b2e\/e7a796b2ef0383c834b49bd80b9e2cd8.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>\u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u043d\u0430\u0441. \u041d\u0430\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f, \u0442\u043e \u0435\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c Async \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435.<\/p>\n<\/li>\n<li>\n<p>return \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u0435\u043d \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0431\u043b\u043e\u043a\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043a\u043e\u0434<\/h3>\n<p>\u0412 \u043b\u0435\u0432\u0443\u044e \u0432\u0435\u0440\u0445\u043d\u0435\u044e \u0441\u0435\u043a\u0446\u0438\u044e AST Explorer \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">async function helloFunction(names = []) {     const namesEdited = names         .map((name) => {             const formattedName = `hello ${name}`;             return formattedName;         });     return namesEdited; }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u0438\u0442\u043e\u0433\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u043b\u0438\u043d\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"javascript\">async function helloFunctionAsync(names = []) {     const namesEdited = names         .map((name) => {             const formattedName = `hello ${name}`;              return formattedName;         });      return namesEdited; }<\/code><\/pre>\n<h3>\u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/h3>\n<p>\u0412 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0440\u0435\u0432\u043e c \u043d\u043e\u0434\u0430\u043c\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c3d\/083\/af3\/c3d083af38e9248bbef7ddc7c6b1d1c2.png\" width=\"928\" height=\"645\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c3d\/083\/af3\/c3d083af38e9248bbef7ddc7c6b1d1c2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 Program -> body \u0432\u0438\u0434\u0438\u043c \u043d\u043e\u0434\u0443 FunctionDeclaration \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0412 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {              },     }; };<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u043e\u0432 FunctionDeclaration, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u043e\u0434\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 Async \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);            if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             \/\/             }         },     }; };<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c65\/3c1\/899\/c653c18994dd63f2758371ef434b7fbd.png\" width=\"650\" height=\"698\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c65\/3c1\/899\/c653c18994dd63f2758371ef434b7fbd.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c `context.report`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 context.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);                  if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             context.report({                 node,                   message: '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Async',                 });             }         },     }; };<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/46d\/fa1\/f0a\/46dfa1f0aa405a0d8f373f78520aa0fa.png\" width=\"683\" height=\"256\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/46d\/fa1\/f0a\/46dfa1f0aa405a0d8f373f78520aa0fa.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 AST Explorer \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c. \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 Fixed output follows \u043d\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 report:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);            if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             context.report({                     node,                     message: '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Async',                     fix: function(fixer) {                          \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438                         const nameToken = context                                 .getTokens(node)                                 .find(token => token.value === node.id.name);                          \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435                         return fixer.replaceText(nameToken, node.id.name + 'Async');                     }                 });             }         },     }; };<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, fixer \u0441\u043c\u043e\u0433 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u043f\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/94c\/8fe\/665\/94c8fe6655c3301174e02bd1eede7394.png\" width=\"667\" height=\"222\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/94c\/8fe\/665\/94c8fe6655c3301174e02bd1eede7394.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0412\u044b\u0434\u0435\u043b\u0438\u0432 \u0441\u043b\u043e\u0432\u043e &#171;return&#187; \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 astexplorer, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0442\u0438\u043f \u043d\u043e\u0434\u044b ReturnStatement. \u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0432 \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {             \/\/ ... \u0442\u0443\u0442 \u043a\u043e\u0434 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u043c         },         ReturnStatement(node) {             \/\/ \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a         },     }; };<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 ReturnStatement \u043d\u0430\u043c \u043d\u0430\u0434\u043e:<\/p>\n<ol>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e return \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441 return \u0443\u0436\u0435 \u043d\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 return \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0438. \u041a\u043e\u0434 \u0441\u043d\u0430\u0431\u0434\u0438\u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438. \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0438\u0436\u0435 \u0432\u0437\u044f\u0442 \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f ESLint.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430     const sourceCode = context.getSourceCode();      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435     function canFix(node) {         const leadingComments = sourceCode.getCommentsBefore(node);         const lastLeadingComment = leadingComments[leadingComments.length - 1];         const tokenBefore = sourceCode.getTokenBefore(node);          if (leadingComments.length === 0) {             return true;         }          if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &amp;&amp;             lastLeadingComment.loc.end.line !== node.loc.start.line) {              return true;         }          return false;     }              \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u043e\u0434\u0435           function getLineNumberOfTokenBefore(node) {       const tokenBefore = sourceCode.getTokenBefore(node);          if (tokenBefore) {         return tokenBefore.loc.end.line;         }          return 0;     }      \/\/ \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0442\u0440\u043e\u043a \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439     function calcCommentLines(node, lineNumTokenBefore) {       const comments = sourceCode.getCommentsBefore(node);          let numLinesComments = 0;          if (!comments.length) {         return numLinesComments;         }          comments.forEach(comment => {         numLinesComments++;              if (comment.type === \"Block\") {         numLinesComments += comment.loc.end.line - comment.loc.start.line;             }              if (comment.loc.start.line === lineNumTokenBefore) {         numLinesComments--;             }              if (comment.loc.end.line === node.loc.start.line) {               numLinesComments--;             }         });          return numLinesComments;     }      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439     function hasNewlineBefore(node) {       const lineNumNode = node.loc.start.line;         const lineNumTokenBefore = getLineNumberOfTokenBefore(node);         const commentLines = calcCommentLines(node, lineNumTokenBefore);          return (lineNumNode - lineNumTokenBefore - commentLines) > 1;     }      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439 \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430     function isPrecededByTokens(node, testTokens) {       const tokenBefore = sourceCode.getTokenBefore(node);          return testTokens.includes(tokenBefore.value);     }      \/\/ \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0434\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435     function isFirstNode(node) {         \/\/ \u0422\u0438\u043f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043d\u043e\u0434\u044b       const parentType = node.parent.type;          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 body, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c         * \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u043d\u043e\u0434\u0430 \u0442\u0435\u043b\u043e\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u043d\u0435\u0439         *\/         if(node.parent.body) {         return Array.isArray(node.parent.body)           ? node.parent.body[0] === node           : node.parent.body === node;         }          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0423\u0441\u043b\u043e\u0432\u0438\u0435\u043c If,         * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \"else\" \u0438\u043b\u0438 \")\"         *\/         if (parentType === \"IfStatement\") {         return isPrecededByTokens(node, ['else', ')']);         }          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u043e\u043c do-while,         * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \"do\"         *\/         if (parentType === \"DoWhileStatement\") {             return isPrecededByTokens(node, [\"do\"]);         }         \/**        * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u043e\u043c switch case,        * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \":\"        *\/         if (parentType === \"SwitchCase\") {            return isPrecededByTokens(node, [\":\"]);         }          \/**         * \u0412\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \")\" \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439         *\/         return isPrecededByTokens(node, [\")\"]);     }      return {         FunctionDeclaration(node) {             \/\/ \u0442\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f         },              ReturnStatement(node) {             if (!isFirstNode(node) &amp;&amp; !hasNewlineBefore(node)) {                 context.report({                     node,                     message: '\u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043e return',                     fix: function(fixer) {                              if (canFix(node)) {                             const tokenBefore = sourceCode.getTokenBefore(node);                             const whitespaces = sourceCode.lines[node.loc.start.line - 1].replace(\/return(.+)\/, '');                             const newlines = node.loc.start.line === tokenBefore.loc.end.line ? `\\n\\n${whitespaces}` : `\\n${whitespaces}`;                                  return fixer.insertTextBefore(node, newlines);                         }                              return null;                     }                 });             }         },     }; };<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u0432\u0438\u0434\u0435\u043d \u0432 \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 AST Explorer.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cdb\/949\/1e7\/cdb9491e766abe66b54cdf5cc29d47ea.png\" width=\"689\" height=\"273\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cdb\/949\/1e7\/cdb9491e766abe66b54cdf5cc29d47ea.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0444\u043e\u0440\u043c\u0438\u0442\u044c \u0432 npm-\u043f\u0430\u043a\u0435\u0442.<\/p>\n<ol>\n<li>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0434\u043b\u044f \u043f\u0430\u043a\u0435\u0442\u0430:<\/strong> `mkdir my-eslint-rules`<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u043a\u0435\u0442:<\/strong> `cd my-eslint-rules &amp;&amp; npm init &#8212;yes`<\/p>\n<\/li>\n<li>\n<p><strong>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b index.js:<\/strong> `touch index.js`<\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043d\u0443\u0442\u0440\u0438 index.js \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u043c \u043d\u0430\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">module.exports = {   rules: {     'async-func-name': {       create: function (context) {         return { \/* \u0442\u0443\u0442 \u043a\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e Async \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 *\/ }       },     },     'new-line-before-return': {         create: function (context) {             return { \/* \u0442\u0443\u0442 \u043a\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u043f\u0435\u0440\u0435\u0434 return *\/ }           },     },   } };<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442 \u0432 \u0433\u0438\u0442-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0430 npmjs.com. \u0414\u043b\u044f \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e.<\/p>\n<ol>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043b\u0438\u043d\u0442\u0435\u0440\u0430: `cd my-project`.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438: `npm i ..\/my-eslint-rules &#8212;save-dev`.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043b\u0438\u043d\u0442\u0435\u0440\u0430 `.eslintrc` \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0430\u0448 \u043f\u043b\u0430\u0433\u0438\u043d \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0430\u0432\u0438\u043b:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"json\">{     \"rules\": {         \"my-eslint-rules\/async-func-name\": \"warn\",         \"my-eslint-rules\/new-line-before-return\": \"warn\"     },     \"plugins\": [\"my-eslint-rules\"] }<\/code><\/pre>\n<blockquote>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d ESLint.<\/p>\n<\/blockquote>\n<h3>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b \u043f\u043e \u0442\u0435\u043c\u0435<\/h3>\n<p><a href=\"https:\/\/eslint.org\/docs\/latest\/developer-guide\/working-with-rules\">\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438. \u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ESLint<\/a><br \/><a href=\"https:\/\/eslint-utils.mysticatea.dev\">\u041f\u0430\u043a\u0435\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0443\u0442\u0438\u043b\u0438\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b<\/a><br \/><a href=\"https:\/\/docs.npmjs.com\/creating-and-publishing-scoped-public-packages\">\u041a\u0430\u043a \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c npm-\u043f\u0430\u043a\u0435\u0442\u044b<\/a><br \/><a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/415269\/\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0435\u0440\u0435\u0432\u044c\u044f\u0445<\/a><\/p>\n<p>\u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u0438\u0437 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432\u0448\u0438\u0445 \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/sovcombank_technologies\/blog\/686662\/\"> https:\/\/habr.com\/ru\/company\/sovcombank_technologies\/blog\/686662\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u044b \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043b\u044f \u043b\u0438\u043d\u0442\u0435\u0440\u0430. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0433\u0443\u0433\u043b\u0435, \u0438 \u0447\u0435\u0440\u0435\u0437 \u0447\u0430\u0441-\u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0431\u044b\u043b\u043e \u0433\u043e\u0442\u043e\u0432\u043e. \u0414\u0435\u043b\u0438\u043c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0430\u0432\u0438\u043b.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0430 \u0442\u043e\u0447\u043d\u0435\u0435 \u0434\u043b\u044f \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0434\u0435\u0440\u0435\u0432\u043e. \u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u2014 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/astexplorer.net\">AST Explorer<\/a>.<\/p>\n<p><strong>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u044f\u0437\u044b\u043a<\/strong> \u2014 JavaScript.<br \/><strong>\u041f\u0430\u0440\u0441\u0435\u0440<\/strong> \u2014 babel-eslint9<br \/><strong>\u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440<\/strong> \u2014 ESLint v4 (\u043c\u043e\u0436\u043d\u043e \u0438 \u0441\u0432\u0435\u0436\u0435\u0435, \u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438 \u0432\u0435\u0440\u0441\u0438\u0438 4)<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ul>\n<li>\n<p>\u0412 \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0417\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>\u041f\u0440\u0438\u0434\u0443\u043c\u0430\u0435\u043c \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u0434\u043b\u044f \u043d\u0430\u0441. \u041d\u0430\u0448\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f, \u0442\u043e \u0435\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c Async \u0432 \u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435.<\/p>\n<\/li>\n<li>\n<p>return \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u0435\u043d \u043e\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0431\u043b\u043e\u043a\u0430 \u043e\u0434\u043d\u043e\u0439 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h3>\u041f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u043a\u043e\u0434<\/h3>\n<p>\u0412 \u043b\u0435\u0432\u0443\u044e \u0432\u0435\u0440\u0445\u043d\u0435\u044e \u0441\u0435\u043a\u0446\u0438\u044e AST Explorer \u0432\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"javascript\">async function helloFunction(names = []) {     const namesEdited = names         .map((name) => {             const formattedName = `hello ${name}`;             return formattedName;         });     return namesEdited; }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432 \u0438\u0442\u043e\u0433\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u043b\u0438\u043d\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"javascript\">async function helloFunctionAsync(names = []) {     const namesEdited = names         .map((name) => {             const formattedName = `hello ${name}`;              return formattedName;         });      return namesEdited; }<\/code><\/pre>\n<h3>\u041f\u0435\u0440\u0432\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<\/h3>\n<p>\u0412 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u043f\u0440\u0430\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0434\u0435\u0440\u0435\u0432\u043e c \u043d\u043e\u0434\u0430\u043c\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e \u0434\u0435\u0440\u0435\u0432\u0443 Program -> body \u0432\u0438\u0434\u0438\u043c \u043d\u043e\u0434\u0443 FunctionDeclaration \u2014 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0412 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435 \u043a\u043e\u0434\u0430 \u0432 \u043d\u0438\u0436\u043d\u0435\u0439 \u043b\u0435\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {              },     }; };<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u043e\u0432 FunctionDeclaration, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u043e\u0434\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>\u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 Async \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);            if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             \/\/             }         },     }; };<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u043e\u0431\u0449\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0443 \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u043c `context.report`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 context.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);                  if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             context.report({                 node,                   message: '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Async',                 });             }         },     }; };<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0430\u0432\u043e\u0439 \u043d\u0438\u0436\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 AST Explorer \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430\u0448\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u043e\u043c. \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 Fixed output follows \u043d\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434 report:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {         const isAsyncFunction = node.async;           const hasAsyncAtEndOfName = \/Async$\/.test(node.id.name);            if (isAsyncFunction &amp;&amp; !hasAsyncAtEndOfName) {             context.report({                     node,                     message: '\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 Async',                     fix: function(fixer) {                          \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438                         const nameToken = context                                 .getTokens(node)                                 .find(token => token.value === node.id.name);                          \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435                         return fixer.replaceText(nameToken, node.id.name + 'Async');                     }                 });             }         },     }; };<\/code><\/pre>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, fixer \u0441\u043c\u043e\u0433 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0435 \u043f\u043e\u0434 \u043f\u0440\u0430\u0432\u0438\u043b\u043e.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u043f\u0438\u0448\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0412\u044b\u0434\u0435\u043b\u0438\u0432 \u0441\u043b\u043e\u0432\u043e &#171;return&#187; \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 astexplorer, \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0442\u0438\u043f \u043d\u043e\u0434\u044b ReturnStatement. \u0414\u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0432 \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">export default function(context) {     return {         FunctionDeclaration(node) {             \/\/ ... \u0442\u0443\u0442 \u043a\u043e\u0434 \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u043c         },         ReturnStatement(node) {             \/\/ \u0437\u0434\u0435\u0441\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a         },     }; };<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 ReturnStatement \u043d\u0430\u043c \u043d\u0430\u0434\u043e:<\/p>\n<ol>\n<li>\n<p>\u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e return \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441 return \u0443\u0436\u0435 \u043d\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 return \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0438. \u041a\u043e\u0434 \u0441\u043d\u0430\u0431\u0434\u0438\u043b\u0438 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438. \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0438\u0436\u0435 \u0432\u0437\u044f\u0442 \u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f ESLint.<\/p>\n<pre><code class=\"javascript\">export default function(context) {     \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430     const sourceCode = context.getSourceCode();      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0435     function canFix(node) {         const leadingComments = sourceCode.getCommentsBefore(node);         const lastLeadingComment = leadingComments[leadingComments.length - 1];         const tokenBefore = sourceCode.getTokenBefore(node);          if (leadingComments.length === 0) {             return true;         }          if (lastLeadingComment.loc.end.line === tokenBefore.loc.end.line &amp;&amp;             lastLeadingComment.loc.end.line !== node.loc.start.line) {              return true;         }          return false;     }              \/\/ \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u043e\u0434\u0435           function getLineNumberOfTokenBefore(node) {       const tokenBefore = sourceCode.getTokenBefore(node);          if (tokenBefore) {         return tokenBefore.loc.end.line;         }          return 0;     }      \/\/ \u041f\u043e\u0434\u0441\u0447\u0435\u0442 \u0441\u0442\u0440\u043e\u043a \u0441 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439     function calcCommentLines(node, lineNumTokenBefore) {       const comments = sourceCode.getCommentsBefore(node);          let numLinesComments = 0;          if (!comments.length) {         return numLinesComments;         }          comments.forEach(comment => {         numLinesComments++;              if (comment.type === \"Block\") {         numLinesComments += comment.loc.end.line - comment.loc.start.line;             }              if (comment.loc.start.line === lineNumTokenBefore) {         numLinesComments--;             }              if (comment.loc.end.line === node.loc.start.line) {               numLinesComments--;             }         });          return numLinesComments;     }      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439     function hasNewlineBefore(node) {       const lineNumNode = node.loc.start.line;         const lineNumTokenBefore = getLineNumberOfTokenBefore(node);         const commentLines = calcCommentLines(node, lineNumTokenBefore);          return (lineNumNode - lineNumTokenBefore - commentLines) > 1;     }      \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u0434 \u043d\u043e\u0434\u043e\u0439 \u043d\u0430 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430     function isPrecededByTokens(node, testTokens) {       const tokenBefore = sourceCode.getTokenBefore(node);          return testTokens.includes(tokenBefore.value);     }      \/\/ \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u043e\u0434\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u0431\u043b\u043e\u043a\u0435     function isFirstNode(node) {         \/\/ \u0422\u0438\u043f \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u043d\u043e\u0434\u044b       const parentType = node.parent.type;          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 body, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c         * \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u0430\u044f \u043d\u043e\u0434\u0430 \u0442\u0435\u043b\u043e\u043c \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0432 \u043d\u0435\u0439         *\/         if(node.parent.body) {         return Array.isArray(node.parent.body)           ? node.parent.body[0] === node           : node.parent.body === node;         }          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0423\u0441\u043b\u043e\u0432\u0438\u0435\u043c If,         * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \"else\" \u0438\u043b\u0438 \")\"         *\/         if (parentType === \"IfStatement\") {         return isPrecededByTokens(node, ['else', ')']);         }          \/**         * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u043e\u043c do-while,         * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \"do\"         *\/         if (parentType === \"DoWhileStatement\") {             return isPrecededByTokens(node, [\"do\"]);         }         \/**        * \u0415\u0441\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0430\u044f \u043d\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043b\u043e\u043a\u043e\u043c switch case,        * \u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439 \u0435\u0441\u0442\u044c \":\"        *\/         if (parentType === \"SwitchCase\") {            return isPrecededByTokens(node, [\":\"]);         }          \/**         * \u0412\u043e \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430 \")\" \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u0448\u0435\u0439 \u043d\u043e\u0434\u043e\u0439         *\/         return isPrecededByTokens(node, [\")\"]);     }      return {         FunctionDeclaration(node) {             \/\/ \u0442\u0443\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f         },              ReturnStatement(node) {             if (!isFirstNode(node) &amp;&amp; !hasNewlineBefore(node)) {                 context.report({                     node,                     message: '\u041f\u043e\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043f\u0443\u0441\u0442\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043e return',                     fix: function(fixer) {                              if (canFix(node)) {                             const tokenBefore = sourceCode.getTokenBefore(node);                             const whitespaces = sourceCode.lines[node.loc.start.line - 1].replace(\/return(.+)\/, '');                             const newlines = node.loc.start.line === tokenBefore.loc.end.line ? `\\n\\n${whitespaces}` : `\\n${whitespaces}`;                                  return fixer.insertTextBefore(node, newlines);                         }                              return null;                     }                 }); <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-338013","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338013"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/338013\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}