
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
eslint-plugin-local
Advanced tools
This ESLint plugin allows you to implement a custom ESLint plugin including custom rules in your repository without installing them as a dependency.
This ESLint plugin allows you to implement a custom ESLint plugin including custom rules in your repository without installing them as a dependency.
Originally inspired by cletusw/eslint-plugin-local-rules.
npm install --save-dev eslint-plugin-local
The JavaScript file named eslint.local.js or eslint-plugin-local.js or .eslint-plugin-local/index.js must be created at the root of your repository, which the file has the content of an ESLint plugin. The extension .cjs can be used in place of .js in case ES module is not supported. For example:
module.exports = {
rules: {
sample: {
// Optional
meta: {
// See https://eslint.org/docs/latest/extend/custom-rules#rule-structure
},
// Mandatory
create: function (context) {
// Implementation goes here
// See https://eslint.org/docs/latest/extend/custom-rules
},
// Optional
// Unit test can be triggered by `eslint-plugin-local test` command
// See https://eslint.org/docs/latest/integrate/nodejs-api#ruletester
tests: {
valid: [...],
invalid: [...],
}
}
}
}
Then add the plugin to your eslint.config.js file:
const local = require('eslint-plugin-local')
module.exports = [{
plugins: {
local
},
rules: {
'local/sample': 'error'
}
}]
Additionally, this package provides eslint-plugin-local test
command out of the box, which it scans for tests: { valid: [], invalid: [] }
field in each rule and runs RuleTester
internally.
To make it easy to debug your test cases, wrap one or more test objects inside the global only()
function. Given the example below, only the first test case and every invalid case will be run.
module.exports = {
rules: {
sample: {
tests: {
valid: [
only({
code: 'var foo = 1',
}),
{
code: 'var foo = 2',
}
],
invalid: only([...]),
}
}
}
}
FAQs
This ESLint plugin allows you to implement a custom ESLint plugin including custom rules in your repository without installing them as a dependency.
The npm package eslint-plugin-local receives a total of 111,670 weekly downloads. As such, eslint-plugin-local popularity was classified as popular.
We found that eslint-plugin-local demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.