Download wp-calypso/packages/eslint-plugin-wpcalypso/test-utils/format-message.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 773 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/eslint-plugin-wpcalypso/test-utils/format-message.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/eslint-plugin-wpcalypso/test-utils/format-message.js
-
curl -L -o format-message.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/eslint-plugin-wpcalypso/test-utils/format-message.js
773 Bytes
| /** | |
| * @file Utility for replacing placeholders in eslint rule messages | |
| * @author Automattic | |
| * @copyright 2016 Automattic. All rights reserved. | |
| * See LICENSE.md file in root directory for full license. | |
| */ | |
| /** | |
| * Given a message containing data terms, format the string using the specified | |
| * terms object. | |
| * @see https://github.com/eslint/eslint/blob/v2.12.0/lib/eslint.js#L964-L971 | |
| * @param {string} message Message template | |
| * @param {Object} terms Terms | |
| * @returns {string} Formatted message | |
| */ | |
| function formatMessage( message, terms ) { | |
| return message.replace( /\{\{\s*(.+?)\s*\}\}/g, function ( fullMatch, term ) { | |
| if ( terms.hasOwnProperty( term ) ) { | |
| return terms[ term ]; | |
| } | |
| return fullMatch; | |
| } ); | |
| } | |
| module.exports = formatMessage; | |