lib/rules/brace-style.js
function validateCurlyPair(openingCurly, closingCurly) {
         const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly),
               tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly),
               tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly),
               singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly),
               isOpeningCurlyOnSameLine = astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly),
               isClosingCurlyOnSameLine = astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly);

         if (style !== 'allman' && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
            context.report({
               node: openingCurly,
               messageId: 'nextLineOpen',
               fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly),
            });
         }

         if (style === 'allman' && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
            context.report({
               node: openingCurly,
               messageId: 'sameLineOpen',
               fix: (fixer) => fixer.insertTextBefore(openingCurly, '\n'),
            });
         }


         if (isOpeningCurlyOnSameLine && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
            context.report({
               node: openingCurly,
               messageId: 'blockSameLine',
               fix: (fixer) => fixer.insertTextAfter(openingCurly, '\n'),
            });
         }

         if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && isClosingCurlyOnSameLine) {
            context.report({
               node: closingCurly,
               messageId: 'singleLineClose',
               fix: (fixer) => fixer.insertTextBefore(closingCurly, '\n'),
            });
         }
      }
function validateCurlyPair(openingCurly, closingCurly) {
         const tokenBeforeOpeningCurly = sourceCode.getTokenBefore(openingCurly),
               tokenAfterOpeningCurly = sourceCode.getTokenAfter(openingCurly),
               tokenBeforeClosingCurly = sourceCode.getTokenBefore(closingCurly),
               singleLineException = params.allowSingleLine && astUtils.isTokenOnSameLine(openingCurly, closingCurly),
               isOpeningCurlyOnSameLine = astUtils.isTokenOnSameLine(openingCurly, tokenAfterOpeningCurly),
               isClosingCurlyOnSameLine = astUtils.isTokenOnSameLine(tokenBeforeClosingCurly, closingCurly);

         if (style !== 'allman' && !astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly)) {
            context.report({
               node: openingCurly,
               messageId: 'nextLineOpen',
               fix: removeNewlineBetween(tokenBeforeOpeningCurly, openingCurly),
            });
         }

         if (style === 'allman' && astUtils.isTokenOnSameLine(tokenBeforeOpeningCurly, openingCurly) && !singleLineException) {
            context.report({
               node: openingCurly,
               messageId: 'sameLineOpen',
               fix: (fixer) => fixer.insertTextBefore(openingCurly, '\n'),
            });
         }


         if (isOpeningCurlyOnSameLine && tokenAfterOpeningCurly !== closingCurly && !singleLineException) {
            context.report({
               node: openingCurly,
               messageId: 'blockSameLine',
               fix: (fixer) => fixer.insertTextAfter(openingCurly, '\n'),
            });
         }

         if (tokenBeforeClosingCurly !== openingCurly && !singleLineException && isClosingCurlyOnSameLine) {
            context.report({
               node: closingCurly,
               messageId: 'singleLineClose',
               fix: (fixer) => fixer.insertTextBefore(closingCurly, '\n'),
            });
         }
      }
function validateCurlyPair ( openingCurly , closingCurly ) { const tokenBeforeOpeningCurly = sourceCode . getTokenBefore ( openingCurly ) , tokenAfterOpeningCurly = sourceCode . getTokenAfter ( openingCurly ) , tokenBeforeClosingCurly = sourceCode . getTokenBefore ( closingCurly ) , singleLineException = params . allowSingleLine && astUtils . isTokenOnSameLine ( openingCurly , closingCurly ) , isOpeningCurlyOnSameLine = astUtils . isTokenOnSameLine ( openingCurly , tokenAfterOpeningCurly ) , isClosingCurlyOnSameLine = astUtils . isTokenOnSameLine ( tokenBeforeClosingCurly , closingCurly ) ; if ( style !== 'allman' && ! astUtils . isTokenOnSameLine ( tokenBeforeOpeningCurly , openingCurly ) ) { context . report ( { node : openingCurly , messageId : 'nextLineOpen' , fix : removeNewlineBetween ( tokenBeforeOpeningCurly , openingCurly ) , } ) ; } if ( style === 'allman' && astUtils . isTokenOnSameLine ( tokenBeforeOpeningCurly , openingCurly ) && ! singleLineException ) { context . report ( { node : openingCurly , messageId : 'sameLineOpen' , fix : ( fixer ) => fixer . insertTextBefore ( openingCurly , '\n' ) , } ) ; } if ( isOpeningCurlyOnSameLine && tokenAfterOpeningCurly !== closingCurly && ! singleLineException ) { context . report ( { node : openingCurly , messageId : 'blockSameLine' , fix : ( fixer ) => fixer . insertTextAfter ( openingCurly , '\n' ) , } ) ; } if ( tokenBeforeClosingCurly !== openingCurly && ! singleLineException && isClosingCurlyOnSameLine ) { context . report ( { node : closingCurly , messageId : 'singleLineClose' , fix : ( fixer ) => fixer . insertTextBefore ( closingCurly , '\n' ) , } ) ; } }
Validates a pair of curly brackets based on the user's config
@param {Token} openingCurly The opening curly bracket
@param {Token} closingCurly The closing curly bracket
@returns {void}
Validates a pair of curly brackets based on the user s config