From 9625b4350a54c43f55841b508e3f86e7d7d6635b Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Tue, 23 Jan 2024 09:27:35 -0300 Subject: [PATCH] chore: Remove mandatory jsdoc (#4180) Fixes #3860 --- yarn-project/accounts/.eslintrc.cjs | 2 +- yarn-project/aztec.js/.eslintrc.cjs | 2 +- yarn-project/foundation/.eslintrc.cjs | 59 +----------------- yarn-project/foundation/.eslintrc.docs.cjs | 69 ++++++++++++++++++++++ yarn-project/foundation/package.json | 1 + 5 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 yarn-project/foundation/.eslintrc.docs.cjs diff --git a/yarn-project/accounts/.eslintrc.cjs b/yarn-project/accounts/.eslintrc.cjs index e659927475c..ec1dd3e14de 100644 --- a/yarn-project/accounts/.eslintrc.cjs +++ b/yarn-project/accounts/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint'); +module.exports = require('@aztec/foundation/eslint.docs'); diff --git a/yarn-project/aztec.js/.eslintrc.cjs b/yarn-project/aztec.js/.eslintrc.cjs index e659927475c..ec1dd3e14de 100644 --- a/yarn-project/aztec.js/.eslintrc.cjs +++ b/yarn-project/aztec.js/.eslintrc.cjs @@ -1 +1 @@ -module.exports = require('@aztec/foundation/eslint'); +module.exports = require('@aztec/foundation/eslint.docs'); diff --git a/yarn-project/foundation/.eslintrc.cjs b/yarn-project/foundation/.eslintrc.cjs index 31c960d6c12..daa6e7a51eb 100644 --- a/yarn-project/foundation/.eslintrc.cjs +++ b/yarn-project/foundation/.eslintrc.cjs @@ -1,41 +1,3 @@ -// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts -const contexts = [ - // All methods in an interface - 'TSInterfaceDeclaration TSMethodSignature', - // All public methods in a class that does not implement an interface - 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', - // TODO: All methods public by default in a class that does not implement an interface - // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', - // TODO: All export const from the top level of a file - // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', - // Legacy contexts (needs review) - 'TSParameterProperty[accessibility=public]', - 'TSPropertySignature', - 'PropertySignature', - 'TSInterfaceDeclaration', - 'InterfaceDeclaration', - 'TSPropertyDefinition[accessibility=public]', - 'PropertyDefinition[accessibility=public]', - 'TSTypeAliasDeclaration', - 'TypeAliasDeclaration', - 'TSTypeDeclaration', - 'TypeDeclaration', - 'TSEnumDeclaration', - 'EnumDeclaration', - 'TSClassDeclaration', - 'ClassDeclaration', - 'TSClassExpression', - 'ClassExpression', - 'TSFunctionExpression', - 'FunctionExpression', - 'TSInterfaceExpression', - 'InterfaceExpression', - 'TSEnumExpression', - 'EnumExpression', -]; - -const JSDOC_RULES_LEVEL = 'error'; - module.exports = { extends: [ 'eslint:recommended', @@ -112,27 +74,8 @@ module.exports = { ], 'import/no-extraneous-dependencies': 'error', 'import/no-cycle': 'warn', - 'tsdoc/syntax': JSDOC_RULES_LEVEL, - 'jsdoc/require-jsdoc': [ - JSDOC_RULES_LEVEL, - { - contexts, - checkConstructors: false, - checkGetters: true, - checkSetters: true, - }, - ], - 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], - 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], - 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], - 'jsdoc/require-returns': 'off', // this unfortunately doesn't block `fit` and `fdescribe` 'no-only-tests/no-only-tests': ['error'], }, - ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs'], + ignorePatterns: ['node_modules', 'dest*', 'dist', '*.js', '.eslintrc.cjs', '.eslintrc.*.cjs'], }; diff --git a/yarn-project/foundation/.eslintrc.docs.cjs b/yarn-project/foundation/.eslintrc.docs.cjs new file mode 100644 index 00000000000..cac8e4f9095 --- /dev/null +++ b/yarn-project/foundation/.eslintrc.docs.cjs @@ -0,0 +1,69 @@ +// See https://typescript-eslint.io/play/#ts=5.1.6&showAST=es&fileType=.ts +const contexts = [ + // All methods in an interface + 'TSInterfaceDeclaration TSMethodSignature', + // All public methods in a class that does not implement an interface + 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=public]', + // TODO: All methods public by default in a class that does not implement an interface + // 'ClassDeclaration[implements.length=0] MethodDefinition[accessibility=undefined][key.type=Identifier]', + // TODO: All export const from the top level of a file + // 'ExportNamedDeclaration[declaration.type=VariableDeclaration]', + // Legacy contexts below (needs review) + 'TSParameterProperty[accessibility=public]', + 'TSPropertySignature', + 'PropertySignature', + 'TSInterfaceDeclaration', + 'InterfaceDeclaration', + 'TSPropertyDefinition[accessibility=public]', + 'PropertyDefinition[accessibility=public]', + 'TSTypeAliasDeclaration', + 'TypeAliasDeclaration', + 'TSTypeDeclaration', + 'TypeDeclaration', + 'TSEnumDeclaration', + 'EnumDeclaration', + 'TSClassDeclaration', + 'ClassDeclaration', + 'TSClassExpression', + 'ClassExpression', + 'TSFunctionExpression', + 'FunctionExpression', + 'TSInterfaceExpression', + 'InterfaceExpression', + 'TSEnumExpression', + 'EnumExpression', +]; + +const base = require('./.eslintrc.cjs'); +const JSDOC_RULES_LEVEL = 'error'; + +module.exports = { + ...base, + plugins: [...base.plugins, 'jsdoc'], + overrides: [ + ...base.overrides, + { files: '*.test.ts', rules: { 'jsdoc/require-jsdoc': 'off' } }, + ], + rules: { + ...base.rules, + 'tsdoc/syntax': JSDOC_RULES_LEVEL, + 'jsdoc/require-jsdoc': [ + JSDOC_RULES_LEVEL, + { + contexts, + checkConstructors: false, + checkGetters: true, + checkSetters: true, + }, + ], + 'jsdoc/require-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-hyphen-before-param-description': [JSDOC_RULES_LEVEL], + 'jsdoc/require-param': [JSDOC_RULES_LEVEL, { contexts, checkDestructured: false }], + 'jsdoc/require-param-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-param-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-description': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-property-name': [JSDOC_RULES_LEVEL, { contexts }], + 'jsdoc/require-returns': 'off', + } +}; diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 0851e5c79d5..35d2d9480e2 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -7,6 +7,7 @@ "types": "./dest/index.d.ts", "exports": { "./eslint": "./.eslintrc.cjs", + "./eslint.docs": "./.eslintrc.docs.cjs", "./prettier": "./.prettierrc.json", "./abi": "./dest/abi/index.js", "./async-map": "./dest/async-map/index.js",