From e349e041195fc982e80bc82ddb6ab2aa1c1293e0 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Thu, 17 Sep 2020 11:01:15 +0200 Subject: [PATCH] refactor: Apply naming-convention rules --- .eslintrc.js | 27 ++++++++++++++++++++++++++- src/util/MetadataController.ts | 6 +++--- src/util/UriConstants.ts | 1 + 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7737cfd29..6bf4f04ec 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,7 +25,6 @@ module.exports = { }, rules: { '@typescript-eslint/lines-between-class-members': [ 'error', { exceptAfterSingleLine: true }], - '@typescript-eslint/naming-convention': 'off', '@typescript-eslint/no-empty-interface': 'off', '@typescript-eslint/no-invalid-void-type': 'off', // breaks with default void in Asynchandler 2nd generic '@typescript-eslint/no-unnecessary-condition': 'off', // problems with optional parameters @@ -48,6 +47,32 @@ module.exports = { 'unicorn/no-fn-reference-in-iterator': 'off', // this prevents some functional programming paradigms 'unicorn/no-object-as-default-parameter': 'off', + // Naming conventions + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'default', + format: ['camelCase'], + leadingUnderscore: 'forbid', + trailingUnderscore: 'forbid', + }, + { + selector: 'variable', + format: ['camelCase', 'UPPER_CASE'], + leadingUnderscore: 'forbid', + trailingUnderscore: 'forbid', + }, + { + selector: 'typeLike', + format: ['PascalCase'], + }, + { + selector: [ 'typeParameter' ], + format: [ 'PascalCase' ], + prefix: [ 'T' ] + } + ], + // Import 'sort-imports': 'off', // Disabled in favor of eslint-plugin-import 'import/order': ['error', { diff --git a/src/util/MetadataController.ts b/src/util/MetadataController.ts index f960048b0..acbf2f988 100644 --- a/src/util/MetadataController.ts +++ b/src/util/MetadataController.ts @@ -13,13 +13,13 @@ import { pipeStreamsAndErrors } from './Util'; export class MetadataController { /** * Helper function to generate quads for a Container or Resource. - * @param URI - The URI for which the quads should be generated. + * @param uri - The URI for which the quads should be generated. * @param stats - The Stats of the subject. * * @returns The generated quads. */ - public generateResourceQuads(URI: string, stats: Stats): Quad[] { - const metadata = new RepresentationMetadata(URI); + public generateResourceQuads(uri: string, stats: Stats): Quad[] { + const metadata = new RepresentationMetadata(uri); if (stats.isDirectory()) { metadata.add(RDF.type, getNamedNode(LDP.Container)); metadata.add(RDF.type, getNamedNode(LDP.BasicContainer)); diff --git a/src/util/UriConstants.ts b/src/util/UriConstants.ts index eaa45ef41..33e376fe1 100644 --- a/src/util/UriConstants.ts +++ b/src/util/UriConstants.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/naming-convention */ const createSuffixFn = (prefix: string): ((suf: string) => string) => (suffix: string): string => `${prefix}${suffix}`; const ACL_PREFIX = createSuffixFn('http://www.w3.org/ns/auth/acl#');