Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(no-deprecated-api): Add ignores option #353

Open
scagood opened this issue Oct 9, 2024 · 3 comments
Open

feat(no-deprecated-api): Add ignores option #353

scagood opened this issue Oct 9, 2024 · 3 comments
Assignees
Labels
enhancement rule:update An update to a current rule

Comments

@scagood
Copy link

scagood commented Oct 9, 2024

It'd be nice to be able to ignore specific deprecation warnings in no-deprecated-api (see #183)

The core of the feature is already implemented in:

ignores: {
type: "array",
items: {
enum: Array.from(
new Set([
...enumeratePropertyNames(traceMap.globals),
...enumeratePropertyNames(traceMap.modules),
])
),
},
uniqueItems: true,
},

/**
* Parses the options.
* @param {import('eslint').Rule.RuleContext} context The rule context.
* @returns {Readonly<{
* version: import('semver').Range;
* ignores: Set<string>;
* allowExperimental: boolean;
* }>} Parsed value.
*/
function parseOptions(context) {
const raw = context.options[0] || {}
const version = getConfiguredNodeVersion(context)
const ignores = new Set(raw.ignores || [])
const allowExperimental = raw.allowExperimental ?? false
return Object.freeze({ version, ignores, allowExperimental })
}

const name = unprefixNodeColon(path.join("."))
if (options.ignores.has(name)) {
continue
}

@MichaelDeBoey
Copy link
Member

@scagood The way this is presented would be a breaking change I guess as currently people don't pass the ignores?

@scagood
Copy link
Author

scagood commented Oct 9, 2024

I dont think this is a breaking change as:

  • ignores is not a required property which defaults to []
  • when ignores = [], then it will default to ignoring nothing

@MichaelDeBoey
Copy link
Member

@scagood Oh my bad, I was reading it as "only the ones mentioned in this array will throw an error", but it's the other way around 😅🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement rule:update An update to a current rule
Projects
None yet
Development

No branches or pull requests

2 participants