This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
export-name: export declarations are not flagged #444
Closed
Description
Suppose I have a file named passLint.ts
:
// $ cat src/failLint.ts
export function fish() : string {
return '🐟';
}
The export-name
rule will rightly complain that the export name does not match.
Suppose that, instead, I write the export on a different line from the function declaration:
// $ cat src/passLint.ts
function fish() : string {
return '🐟';
}
export { fish }
export-name
fails to fire on this, even though it results in identical javascript output:
// $ tsc; cat src/failLint.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function fish() {
return '🐟';
}
exports.fish = fish;
// $ diff src/*.js # produces no output because files match
All source code for a minimal example:
$ for x in $( git ls-files | grep -v yarn ); do echo;echo "# $x"; cat $x; done
# .gitignore
node_modules
yarn-error.log
# package.json
{
"name": "tmp.xj0vgsu2jj",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "tslint --format stylish --project ."
},
"author": "",
"license": "UNLICENCED",
"devDependencies": {
"tslint": "^5.10.0",
"tslint-microsoft-contrib": "^5.0.3",
"typescript": "2.9.2"
}
}
# src/failLint.ts
export function fish() : string {
return '🐟';
}
# src/passLint.ts
function fish() : string {
return '🐟';
}
export { fish };
# tsconfig.json
{
"compilerOptions": {
/* Basic Options */
"target": "ES5",
"lib": [ // Specify library files to be included in the compilation.
"es2015",
"es2017"
],
/* Strict Type-Checking Options */
"strict": true, // Enable all strict type-checking options.
"strictNullChecks": true, // Enable strict null checks.
/* Additional Checks */
"noUnusedLocals": true, // Report errors on unused locals.
"noUnusedParameters": true, // Report errors on unused parameters.
"noImplicitReturns": true, // Report error when not all code paths in function return a value.
"noFallthroughCasesInSwitch": true, // Report errors for fallthrough cases in switch statement.
/* Module Resolution Options */
"moduleResolution": "node", // Specify module resolution strategy.
"allowSyntheticDefaultImports": true, // Allow default imports from modules with no default export. This does not affect code emit, just typechecking.
"esModuleInterop": true, // Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports.
},
"exclude": ["node_modules/"]
}
# tslint.yml
extends:
- tslint-microsoft-contrib # https://github.com/Microsoft/tslint-microsoft-contrib/blob/master/recommended_ruleset.js
rules:
missing-jsdoc: false