Skip to content

Commit

Permalink
Update run-rules-on-codebase settings (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Feb 9, 2022
1 parent 361a060 commit ba9d53c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
11 changes: 10 additions & 1 deletion package.json
Expand Up @@ -110,7 +110,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
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
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
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

0 comments on commit ba9d53c

Please sign in to comment.