Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
16 changes: 6 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import javascriptConfig from '@playcanvas/eslint-config/javascript';
import { esmScriptTags } from '@playcanvas/eslint-config';
import globals from 'globals';

// Extract or preserve existing JSDoc tags
const jsdocRule = playcanvasConfig.find(
config => config.rules && config.rules['jsdoc/check-tag-names']
);
const existingTags = jsdocRule?.rules['jsdoc/check-tag-names'][1]?.definedTags || [];

export default [
...playcanvasConfig,
...javascriptConfig,
{
files: ['**/*.js', '**/*.mjs'],
languageOptions: {
Expand All @@ -32,8 +27,9 @@ export default [
'jsdoc/check-tag-names': [
'error',
{
// custom mjs script tags to not error on, add them to those from parent config
definedTags: [...new Set([...existingTags, 'range', 'step', 'precision'])]
// esmScriptTags (range/step/precision included) plus the shared config's own
// extra tags, which this override would otherwise drop by replacing the rule
definedTags: [...new Set([...esmScriptTags, 'alpha', 'beta', 'category', 'import'])]
}
]
}
Expand Down
33 changes: 4 additions & 29 deletions examples/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import playcanvasConfig from '@playcanvas/eslint-config';
import javascriptConfig from '@playcanvas/eslint-config/javascript';
import reactConfig from '@playcanvas/eslint-config/react';
import globals from 'globals';

import { COLOR_NAMES, INLINE_MD_PATTERN, SAFE_URL_PATTERN } from './utils/inline-markdown.mjs';
Expand Down Expand Up @@ -298,27 +299,9 @@ const importOrder = ['error', {
alphabetize: { order: 'asc', caseInsensitive: true }
}];

// minimal jsx-uses-vars: mark JSX-referenced identifiers as used so no-unused-vars sees imported
// components (e.g. <Panel/>) as used. Avoids pulling in eslint-plugin-react just for this.
const jsxUsesVars = {
meta: { type: 'problem' },
create(context) {
return {
JSXOpeningElement(node) {
let name = node.name;
while (name.type === 'JSXMemberExpression') {
name = name.object;
}
if (name.type === 'JSXIdentifier') {
context.sourceCode.markVariableAsUsed(name.name, name);
}
}
};
}
};

export default [
...playcanvasConfig,
...javascriptConfig,
...reactConfig,
{
files: ['**/*.js', '**/*.mjs', '**/*.jsx'],
languageOptions: {
Expand All @@ -339,15 +322,7 @@ export default [
},
{
files: ['**/*.jsx'],
plugins: {
jsx: {
rules: {
'uses-vars': jsxUsesVars
}
}
},
rules: {
'jsx/uses-vars': 'error',
'max-len': ['error', {
code: 100,
ignoreUrls: true,
Expand Down
Loading
Loading