Skip to content

Commit

Permalink
Update to ESLint v9.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: a877280ec0a26692cc1a8aa394eed592d87ab640
  • Loading branch information
cpojer committed Jan 10, 2025
1 parent 075aad5 commit 457b17c
Show file tree
Hide file tree
Showing 13 changed files with 505 additions and 522 deletions.
136 changes: 0 additions & 136 deletions .eslintrc.cjs

This file was deleted.

1 change: 0 additions & 1 deletion athena/map/Unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class DryUnit {
format() {
const { ammo: a, health, statusEffect } = this;
const ammo = a?.size ? { ammo: [...a] } : null;
// eslint-disable-next-line sort-keys-fix/sort-keys-fix
return {
health,
...ammo,
Expand Down
24 changes: 17 additions & 7 deletions eslint-plugin/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
module.exports = {
import noCopyExpression from './no-copy-expression.js';
import noDateNow from './no-date-now.js';
import noInlineCSS from './no-inline-css.js';
import noLazyImport from './no-lazy-import.js';
import requireUseEffectArguments from './require-use-effect-arguments.js';
import useRelayTypes from './use-relay-types.js';

export default {
configs: {
strict: {
rules: {
Expand All @@ -11,12 +18,15 @@ module.exports = {
},
},
},
meta: {
name: '@deities',
},
rules: {
'no-copy-expression': require('./no-copy-expression'),
'no-date-now': require('./no-date-now'),
'no-inline-css': require('./no-inline-css'),
'no-lazy-import': require('./no-lazy-import'),
'require-use-effect-arguments': require('./require-use-effect-arguments'),
'use-relay-types': require('./use-relay-types'),
'no-copy-expression': noCopyExpression,
'no-date-now': noDateNow,
'no-inline-css': noInlineCSS,
'no-lazy-import': noLazyImport,
'require-use-effect-arguments': requireUseEffectArguments,
'use-relay-types': useRelayTypes,
},
};
45 changes: 23 additions & 22 deletions eslint-plugin/no-copy-expression.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
module.exports.meta = {
fixable: false,
hasSuggestions: false,
type: 'problem',
};

module.exports.create = function noCopyExpression(context) {
return {
CallExpression(node) {
if (
node.callee.type === 'MemberExpression' &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'copy' &&
node.parent.type === 'ExpressionStatement'
) {
context.report({
message: `'copy' calls are side-effect free. Did you forgot to assign the result of this call?`,
node,
});
}
},
};
export default {
create(context) {
return {
CallExpression(node) {
if (
node.callee.type === 'MemberExpression' &&
node.callee.property.type === 'Identifier' &&
node.callee.property.name === 'copy' &&
node.parent.type === 'ExpressionStatement'
) {
context.report({
message: `'copy' calls are side-effect free. Did you forgot to assign the result of this call?`,
node,
});
}
},
};
},
meta: {
fixable: false,
hasSuggestions: false,
type: 'problem',
},
};
2 changes: 1 addition & 1 deletion eslint-plugin/no-date-now.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
create(context) {
return {
CallExpression(node) {
Expand Down
70 changes: 36 additions & 34 deletions eslint-plugin/no-inline-css.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
module.exports.meta = {
fixable: false,
hasSuggestions: false,
type: 'problem',
};

module.exports.create = function noInlineCSS(context) {
return {
TaggedTemplateExpression(node) {
const parent = node.parent;
const nodeToCheck =
(parent?.type === 'ArrowFunctionExpression' && parent.body === node) ||
(parent?.parent?.parent?.type === 'ExportNamedDeclaration' &&
parent.init === node)
? parent
: parent.type === 'Property' &&
parent.value === node &&
parent.parent?.type === 'ObjectExpression'
? parent.parent
: node;
export default {
create(context) {
return {
TaggedTemplateExpression(node) {
const parent = node.parent;
const nodeToCheck =
(parent?.type === 'ArrowFunctionExpression' &&
parent.body === node) ||
(parent?.parent?.parent?.type === 'ExportNamedDeclaration' &&
parent.init === node)
? parent
: parent.type === 'Property' &&
parent.value === node &&
parent.parent?.type === 'ObjectExpression'
? parent.parent
: node;

if (
node.tag.type === 'Identifier' &&
node.tag.name === 'css' &&
nodeToCheck.parent?.parent?.type !== 'Program' &&
nodeToCheck.parent?.parent?.parent?.type !== 'Program'
) {
context.report({
message:
'`css` template literals can only be used at the module top-level.',
node,
});
}
},
};
if (
node.tag.type === 'Identifier' &&
node.tag.name === 'css' &&
nodeToCheck.parent?.parent?.type !== 'Program' &&
nodeToCheck.parent?.parent?.parent?.type !== 'Program'
) {
context.report({
message:
'`css` template literals can only be used at the module top-level.',
node,
});
}
},
};
},
meta: {
fixable: false,
hasSuggestions: false,
type: 'problem',
},
};
41 changes: 21 additions & 20 deletions eslint-plugin/no-lazy-import.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
module.exports.meta = {
fixable: false,
hasSuggestions: false,
type: 'problem',
};

module.exports.create = function noFbtImport(context) {
return {
ImportDeclaration(node) {
if (node.source.value === 'react') {
for (const specifier of node.specifiers) {
if (specifier.imported && specifier.imported.name === 'lazy') {
context.report({
message: `Importing 'lazy' from 'react' is forbidden. Use '@deities/ui/lib/lazy.tsx' instead.`,
node: specifier,
});
break;
export default {
create(context) {
return {
ImportDeclaration(node) {
if (node.source.value === 'react') {
for (const specifier of node.specifiers) {
if (specifier.imported && specifier.imported.name === 'lazy') {
context.report({
message: `Importing 'lazy' from 'react' is forbidden. Use '@deities/ui/lib/lazy.tsx' instead.`,
node: specifier,
});
break;
}
}
}
}
},
};
},
};
},
meta: {
fixable: false,
hasSuggestions: false,
type: 'problem',
},
};
1 change: 1 addition & 0 deletions eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"url": "git://github.com/nkzw-tech/athena-crisis.git"
},
"author": "Christoph Nakazawa <[email protected]>",
"type": "module",
"main": "./index.js"
}
13 changes: 6 additions & 7 deletions eslint-plugin/require-use-effect-arguments.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
module.exports.meta = {
fixable: false,
hasSuggestions: false,
type: 'problem',
};

module.exports = {
export default {
create(context) {
const useEffectNames = new Set();
return {
Expand Down Expand Up @@ -46,4 +40,9 @@ module.exports = {
},
};
},
meta: {
fixable: false,
hasSuggestions: false,
type: 'problem',
},
};
Loading

0 comments on commit 457b17c

Please sign in to comment.