自定义插件
eslint.config.js
js
import local from './my-local-plugin.js'
export default [
{
plugins: {
local,
},
rules: {
'local/rule1': 'warn',
},
},
]my-local-plugin.js
js
const plugin = {
meta: {
name: 'eslint-plugin-local',
version: '1.2.3',
},
rules: {
rule1: {
meta: {
type: 'layout',
docs: {
description:
'Enforce linebreaks after opening and before closing array brackets',
},
name: 'rule1',
fixable: 'whitespace',
},
create(context) {
// rule implementation ...
},
},
},
}
// for ESM
// export default plugin;
// OR for CommonJS
module.exports = plugin