max-lines
强制每个文件的最大行数
有些人认为大文件是代码异味。大文件往往会做很多事情,并且很难跟踪正在发生的事情。虽然文件中没有被认为可接受的客观最大行数,但大多数人会同意它不应该是数千行。建议通常在 100 到 500 行之间。
规则详情
此规则强制每个文件的最大行数,以帮助可维护性并降低复杂性。
请注意,如果文件以换行符结尾,大多数编辑器会在末尾显示一个额外的空行。此规则不计算该额外行。
选项
此规则有一个数字或对象选项:
- nnwbiMyDlQL2SLxhomFENP5EPW4f7/6pR5Futd5BlT6Ki0c7qn9lzgp1cxQ0u5/p3EVdxltD4chDG6K7hicyv9jZUfnL5GyeqpzrHTbJX1bmxc1WgS4LHk2OMn5sD9WwdbMdzYqnF5BSrOcvmZcNGGRc6stRR+BEFyOB3Ne5R7Rq3kHhzroUhQhuD9d41lJqVTzc619N5S3mfGMjumgeuns6DJg3NsJgRSIQ74aPZA1cDeHiYwyWhiKH4Cg6grWr8S5k/4Ct0BwknjdcPTQ7edwuyYnRox/U+GZh6FjfpPdNMei/1DrpTRHzaCPghtQqcyyd/CsjkutwoR3xrhN08YxBJ7844sz9SERGpMQ/zlE=
max
7jd2bhXiUGDmBKu+cZeo8q9FHH9BbCCMY2Txw3OX9o1vUIVm7mRO6gg/tyo+f/SroGDwCXkQyk8bHpOTDz70bQ==
/*eslint max-lines: ["error", 2]*/
var a,
b,
c;
/*eslint max-lines: ["error", 2]*/
var a,
b,c;
/*eslint max-lines: ["error", 2]*/
// a comment
var a,
b,c;
NwldEOIuHKyv0R+3pkUiuSlq7yzV1WsYiQ97qEISbUxtZpTZrsAcn1Vqi9A3WOVgS2j2kBCCnyXbPMTzPeBd/g==
/*eslint max-lines: ["error", 2]*/
var a,
b, c;
/*eslint max-lines: ["error", 2]*/
var a, b, c;
/*eslint max-lines: ["error", 2]*/
// a comment
var a, b, c;
skipBlankLines
Bv4sMSnguAQJ4kJJZCKogrLL0X1/14EwTB4wnie3JQEFMgGrN799xkfPmnyIXT8hiyKEbyiIAu/FB/NXw8V4/IxHPwHDZfD2iyA1Vfinqn8vppioBb+YzugS6XueT7ku
/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
var a,
b,
c;
Bv4sMSnguAQJ4kJJZCKogrLL0X1/14EwTB4wnie3JQEFMgGrN799xkfPmnyIXT8hiyKEbyiIAu/FB/NXw8V4/J4PEcPslkcNaKcvFxlcuhN3b9vLqle4k1j+uhLtUE8g
/*eslint max-lines: ["error", {"max": 2, "skipBlankLines": true}]*/
var a,
b, c;
skipComments
Bv4sMSnguAQJ4kJJZCKogplIQb/FhykEs1m4A3en/oWknpPf1JS2xex83txUNlZ0pz5TKjDVgbB45LDQ6SLsfxCWHkcroNmGxbmTq6UJ0SCb80bs4vYB3FDRvTIE7bSa
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
b,
c;
Bv4sMSnguAQJ4kJJZCKogplIQb/FhykEs1m4A3en/oWknpPf1JS2xex83txUNlZ0kPY/aMVCUlQZMfJoOOMYRV36uNapkJ0kafEqNIJ9cwBoZ1TqlRCHeeHbYer7wkSV
/*eslint max-lines: ["error", {"max": 2, "skipComments": true}]*/
// a comment
var a,
b, c;
何时不使用
q6q/rxye49cB7pAQV1i0eobO4BeYHhSWPO5PvczpSD2eJ41M+tpihdFb4useSV/DQM78dxq/0l05FQBG4wGSaQ==
兼容性
- sC+/tsaGFq/I8VuKhNqr8ivKrZJInVKABreiT6/tCqx64UDvmWnwkKpyveGrtgjDIikB3yS/T0pWIQqcEZMpRTwBIo6AY6JXUbU9AeD3X72k3avffZfxSm5MhhKKjQ0167Anpe7nwLY7ZGApF+w0Og==