template-curly-spacing
要求或禁止模板字符串的嵌入表达式周围有空格
一些该规则报告的问题可以通过 --fix 命令行选项 自动修复
我们可以使用一对 ${
和 }
在模板字符串中嵌入表达式。
此规则可以根据样式指南强制在花括号对中使用间距。
let hello = `hello, ${people.name}!`;
规则详情
此规则旨在保持模板字面内部间距的一致性。
选项
{
"template-curly-spacing": ["error", "never"]
}
GrNq2fetYiou0eUGLFslKfTlFB1upFTV4Q05IgwtMALjyLs3+zfkfZATnKH41xiQNNAu57u+rMas2UOAZ6yxy9PdMWcidy4VU1MGE7tozJOOOxrYnfRdozKo8VKVaI33
- E5eCoRW2aBnbzryLfenjjbNWkVIOaWigHptAu298vHQDn11MYzjC03E3SShAwM+RacNlZ6JD/vEAKEkHEFBSJJUhvLqHdXLQvhkrckwVvdId/+2oEvvSeWLVjZ5XTeyqZ1oBvjEl8cQxogOKv6AC+KfPKldIp0ivwU+jTNJ8URPM6dAe5R7awP1nzqMd5NtDXwajwluGI8OqE4dWt9FhMyLBPBMoLxP7OCwlXeORY9A=
示例
never
0ntIbJ0OAORZP5+MP+H+w2k4NpF4m9ATKg099O4ku42wluZb73+Pmkk7PQQZqG1DKTnJ7RuQGQji/5zdzXFoHpVzoqCtY0CLIGKeeOnHe2U=
/*eslint template-curly-spacing: "error"*/
`hello, ${ people.name}!`;
`hello, ${people.name }!`;
`hello, ${ people.name }!`;
0ntIbJ0OAORZP5+MP+H+w2k4NpF4m9ATKg099O4ku42wluZb73+Pmkk7PQQZqG1DvRq/p6mHQZ9bLifx74hvGTQHWu02lRgIp3pNVN0v6gk=
/*eslint template-curly-spacing: "error"*/
`hello, ${people.name}!`;
`hello, ${
people.name
}!`;
always
5nEv4RCYCaBiSjFxJ4F/mKpeHlEIrnzbcqjXOckHJ1AJ0xAHd//XhiviWDbH1IuAqaAyJgfXNGoYxXmr3KHkzg8n3n6+Byg3bZng9pMLAqY=
/*eslint template-curly-spacing: ["error", "always"]*/
`hello, ${ people.name}!`;
`hello, ${people.name }!`;
`hello, ${people.name}!`;
5nEv4RCYCaBiSjFxJ4F/mKpeHlEIrnzbcqjXOckHJ1BfWqE5nzuNHhp5glzX4UAfCadSKulj2RmmZJMOk1cyb5bLx+vIqzR6ie39IF3MWi8=
/*eslint template-curly-spacing: ["error", "always"]*/
`hello, ${ people.name }!`;
`hello, ${
people.name
}!`;
何时不使用
AabQI/iXeQOz++8V6qDPQ68CR6DWxNAUxWnDjTKd8DltQL1LaHglWfDLYHBjznpwFz/4vmw+6gjQm/ZHgRf0/9wGvbp92+7scARdajkhgfIMFv15tVK+wINcZnmSsCpuhFw2QYoT2sJh4/2Ht0E68w==