Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: use no-restricted-syntax to enforce created options in rules#6074

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions.eslintrc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -264,6 +264,16 @@ module.exports = {

// specifically for rules - default exports makes the tooling easier
'import/no-default-export': 'off',

'no-restricted-syntax': [
'error',
{
selector:
'ExportDefaultDeclaration Property[key.name="create"] MemberExpression[object.name="context"][property.name="options"]',
message:
"Retrieve options from create's second parameter so that defaultOptions are applied.",
},
],
},
},
// plugin rule tests
Expand Down
1 change: 1 addition & 0 deletionspackages/eslint-plugin/src/rules/brace-style.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ export default createRule<Options, MessageIds>({
defaultOptions: ['1tbs'],
create(context) {
const [style, { allowSingleLine } = { allowSingleLine: false }] =
// eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules.
context.options;

const isAllmanStyle = style === 'allman';
Expand Down
4 changes: 1 addition & 3 deletionspackages/eslint-plugin/src/rules/no-unused-vars.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,7 +84,7 @@ export default util.createRule<Options, MessageIds>({
},
},
defaultOptions: [{}],
create(context) {
create(context, [firstOption]) {
const filename = context.getFilename();
const sourceCode = context.getSourceCode();
const MODULE_DECL_CACHE = new Map<TSESTree.TSModuleDeclaration, boolean>();
Expand All@@ -97,8 +97,6 @@ export default util.createRule<Options, MessageIds>({
caughtErrors: 'none',
};

const [firstOption] = context.options;

if (firstOption) {
if (typeof firstOption === 'string') {
options.vars = firstOption;
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,6 +31,7 @@ export default createRule<Options, MessageIds>({
},
defaultOptions: ['never'],
create(context) {
// eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules.
const [firstOption, secondOption] = context.options;
const spaced = firstOption === 'always';
const sourceCode = context.getSourceCode();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -634,6 +634,7 @@ export default util.createRule<Options, MessageIds>({
defaultOptions: [],
create(context) {
const sourceCode = context.getSourceCode();
// eslint-disable-next-line no-restricted-syntax -- We need all raw options.
const configureList = context.options || [];

type Scope = null | {
Expand Down
3 changes: 1 addition & 2 deletionspackages/eslint-plugin/src/rules/space-before-blocks.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,9 +29,8 @@ export default util.createRule<Options, MessageIds>({
},
},
defaultOptions: ['always'],
create(context) {
create(context, [config]) {
const rules = baseRule.create(context);
const config = context.options[0];
const sourceCode = context.getSourceCode();

let requireSpace = true;
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp