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

Update run-rules-on-codebase settings #1720

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,16 @@
"test/integration/{fixtures,fixtures-local}/**"
],
"rules": {
"unicorn/no-null": "error"
"unicorn/no-null": "error",
"unicorn/prefer-array-flat": [
"error",
{
"functions": [
"flat",
"flatten"
]
}
]
},
"overrides": [
{
Expand Down
4 changes: 2 additions & 2 deletions rules/template-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const create = context => {
options.comments = options.comments.map(comment => comment.toLowerCase());

const selectors = [
...options.tags.map(tag => `TaggedTemplateExpression[tag.name="${tag}"] > .quasi`),
...options.functions.map(fn => `CallExpression[callee.name="${fn}"] > .arguments`),
...options.tags.map(tagName => `TaggedTemplateExpression[tag.name="${tagName}"] > .quasi`),
...options.functions.map(functionName => `CallExpression[callee.name="${functionName}"] > .arguments`),
...options.selectors,
];

Expand Down
38 changes: 19 additions & 19 deletions test/no-useless-promise-resolve-reject.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,34 @@ test({
`,
]),
// Sync function returning Promise.resolve/reject
...['resolve, reject'].flatMap(fn => [
`() => Promise.${fn}(bar);`,
...['resolve, reject'].flatMap(method => [
`() => Promise.${method}(bar);`,
outdent`
() => {
return Promise.${fn}(bar);
return Promise.${method}(bar);
};
`,
outdent`
function foo() {
return Promise.${fn}(bar);
return Promise.${method}(bar);
};
`,
outdent`
(function() {
return Promise.${fn}(bar);
return Promise.${method}(bar);
});
`,
]),
// Sync generator yielding Promise.resolve/reject
...['resolve', 'reject'].flatMap(fn => [
...['resolve', 'reject'].flatMap(method => [
outdent`
function * foo() {
yield Promise.${fn}(bar);
yield Promise.${method}(bar);
}
`,
outdent`
(function * () {
yield Promise.${fn}(bar);
yield Promise.${method}(bar);
})
`,
]),
Expand All @@ -72,9 +72,9 @@ test({
}
`,
// Delegate yield expressions
...['resolve', 'reject'].map(fn => outdent`
...['resolve', 'reject'].map(method => outdent`
async function * foo() {
yield* Promise.${fn}(bar);
yield* Promise.${method}(bar);
}
`),
// Promise#then/catch/finally
Expand Down Expand Up @@ -477,26 +477,26 @@ test({
errors: [yieldRejectError],
})),
// Promise#then/catch/finally callbacks returning Promise.resolve/reject
...['then', 'catch', 'finally'].flatMap(fn => [
...['then', 'catch', 'finally'].flatMap(method => [
{
code: `promise.${fn}(() => Promise.resolve(bar))`,
code: `promise.${method}(() => Promise.resolve(bar))`,
errors: [returnResolveError],
output: `promise.${fn}(() => bar)`,
output: `promise.${method}(() => bar)`,
},
{
code: `promise.${fn}(() => { return Promise.resolve(bar); })`,
code: `promise.${method}(() => { return Promise.resolve(bar); })`,
errors: [returnResolveError],
output: `promise.${fn}(() => { return bar; })`,
output: `promise.${method}(() => { return bar; })`,
},
{
code: `promise.${fn}(async () => Promise.reject(bar))`,
code: `promise.${method}(async () => Promise.reject(bar))`,
errors: [returnRejectError],
output: `promise.${fn}(async () => { throw bar; })`,
output: `promise.${method}(async () => { throw bar; })`,
},
{
code: `promise.${fn}(async () => { return Promise.reject(bar); })`,
code: `promise.${method}(async () => { return Promise.reject(bar); })`,
errors: [returnRejectError],
output: `promise.${fn}(async () => { throw bar; })`,
output: `promise.${method}(async () => { throw bar; })`,
},
]),
{
Expand Down
20 changes: 0 additions & 20 deletions test/run-rules-on-codebase/lint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,10 @@ const eslint = new ESLint({
'test/integration/fixtures-local',
],
rules: {
'unicorn/prevent-abbreviations': [
'error',
{
replacements: {
fn: false,
},
},
],
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1109#issuecomment-782689255
'unicorn/consistent-destructuring': 'off',
// Buggy
'unicorn/custom-error-definition': 'off',
'unicorn/prefer-array-flat': [
'error',
{
functions: [
'flat',
'flatten',
],
},
],
// Annoying
'unicorn/no-keyword-prefix': 'off',
'unicorn/no-unsafe-regex': 'off',
Expand All @@ -51,10 +34,7 @@ const eslint = new ESLint({
// Not ready yet
'unicorn/prefer-string-replace-all': 'off',
'unicorn/prefer-top-level-await': 'off',
'unicorn/prefer-object-has-own': 'off',
'unicorn/prefer-at': 'off',
// TODO: Turn this on when `xo` updated `eslint-plugin-unicorn`
'unicorn/relative-url-style': 'off',
},
overrides: [
{
Expand Down