好像eslint有这个配置,可以控制文件尾是否插入空白行
在 eslint.config.mjs 中添加 'eol-last': ['error', 'never']
规则解决了
export default tsEslint.config({
files: ['**/*.ts'],
ignores: ['**/.prettierrc.js'],
extends: [
eslintJS.configs.recommended,
...tsEslint.configs.recommended,
...tsEslint.configs.stylistic,
...angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
rules: {
'eol-last': ['error', 'never'],
},
});
方法 1:配置 .prettierrc
在项目根目录下创建或编辑 .prettierrc 文件,添加以下配置:
{
"endOfLine": "lf",
"insertFinalNewline": true
}
endOfLine: 确保统一的换行符格式。
insertFinalNewline: 确保文件末尾添加一个空白行。
没有用过Prettier,我用的eslint
– echo_lovely 5个月前@echo_lovely: 没有
– dudu 5个月前insertFinalNewline
这个配置 https://prettier.io/docs/options@dudu: 我也看到没有这个配置项,但是搜索的时候,bing的搜索助手给出了这个配置
– echo_lovely 5个月前@echo_lovely: 不知道自己不知道的,玩文字游戏编造答案是目前AI的局限之处
– dudu 5个月前@dudu: 好像eslint有这个配置,可以控制文件尾是否插入空白行,我记得我见过这个配置项
– echo_lovely 5个月前@dudu: https://www.cnblogs.com/yummylucky/p/11217168.html
– echo_lovely 5个月前@echo_lovely: 感谢,用 eslint.配置可以解决,对应的配置是
– dudu 5个月前eol-last
,eslint 配置也会对 prettier 起作用,结果就是先增加一行然后这行被立马删除@echo_lovely: 麻烦你提交一下回答
– dudu 5个月前