// MIT license, Copyright (c) GitHub, Inc. // https://github.com/github/eslint-plugin-github/blob/main/lib/rules/unescaped-html-literal.js /* eslint-disable no-template-curly-in-string */ import rule from './unescaped-html-literal.ts'; import {RuleTester} from 'eslint'; class VitestRuleTester extends RuleTester { static describe = describe; static it = it; static itOnly = it.only; } const ruleTester = new VitestRuleTester(); ruleTester.run('unescaped-html-literal', rule, { valid: [ { code: '`Hello World!`;', languageOptions: {ecmaVersion: 2017}, }, { code: "'Hello World!'", languageOptions: {ecmaVersion: 2017}, }, { code: '"Hello World!"', languageOptions: {ecmaVersion: 2017}, }, { code: 'const helloTemplate = () => html`
Hello World!
`;', languageOptions: {ecmaVersion: 2017}, }, { code: 'const helloTemplate = (name) => html`
Hello ${name}!
`;', languageOptions: {ecmaVersion: 2017}, }, ], invalid: [ { code: "const helloHTML = '
Hello, World!
'", languageOptions: {ecmaVersion: 2017}, errors: [ { message: 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.', }, ], }, { code: 'const helloHTML = "

Hello, World!

"', languageOptions: {ecmaVersion: 2017}, errors: [ { message: 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.', }, ], }, { code: 'const helloHTML = `
Hello ${name}!
`', languageOptions: {ecmaVersion: 2017}, errors: [ { message: 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.', }, ], }, { code: 'const helloHTML = ` \n\t
Hello ${name}!
`', languageOptions: {ecmaVersion: 2017}, errors: [ { message: 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.', }, ], }, { code: 'const helloHTML = foo`
Hello ${name}!
`', languageOptions: {ecmaVersion: 2017}, errors: [ { message: 'Unescaped HTML literal. Use html`` tag template literal for secure escaping.', }, ], }, ], });