Skip to content

Commit 0cc69d1

Browse files
authored
Gentype: suppress lints from generated files (#6442)
1 parent 78b3172 commit 0cc69d1

File tree

82 files changed

+1753
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1753
-555
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#### :nail_care: Polish
2727

2828
- Add [`Deno`](https://deno.land/api?s=Deno) to reserved names, so that modules named `Deno` don't clash with the globally exposed `Deno` object. https://github.com/rescript-lang/rescript-compiler/pull/6428
29+
- Disable ESLint/TSLint on gentype outputs properly. https://github.com/rescript-lang/rescript-compiler/pull/6442
2930

3031
# 11.0.0-rc.4
3132

jscomp/gentype/EmitType.ml

+8-19
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ open GenTypeCommon
33
let fileHeader ~sourceFile =
44
let makeHeader ~lines =
55
match lines with
6-
| [line] -> "/* " ^ line ^ " */\n"
6+
| [line] -> "/* " ^ line ^ " */\n\n"
77
| _ ->
88
"/** \n"
99
^ (lines |> List.map (fun line -> " * " ^ line) |> String.concat "\n")
10-
^ "\n */\n"
10+
^ "\n */\n\n"
1111
in
1212
makeHeader
1313
~lines:["TypeScript file generated from " ^ sourceFile ^ " by genType."]
14-
^ "/* eslint-disable import/first */\n\n"
14+
^ "/* eslint-disable */\n" ^ "/* tslint:disable */\n"
1515

1616
let interfaceName ~(config : Config.t) name =
1717
match config.exportInterfaces with
@@ -183,8 +183,7 @@ let rec renderType ~(config : Config.t) ?(indent = None) ~typeNameIsInterface
183183
in
184184
let tagField =
185185
case |> labelJSToString
186-
|> field
187-
~name:(Runtime.jsVariantTag ~polymorphic:false ~tag)
186+
|> field ~name:(Runtime.jsVariantTag ~polymorphic:false ~tag)
188187
in
189188
match (unboxed, type_) with
190189
| true, type_ ->
@@ -355,20 +354,15 @@ let emitExportType ~(config : Config.t) ~emitters ~nameAs ~opaque ~type_
355354
| true -> "any"
356355
| false -> typeVars |> String.concat " | "
357356
in
358-
"// tslint:disable-next-line:max-classes-per-file \n"
359-
^ (match String.capitalize_ascii resolvedTypeName <> resolvedTypeName with
360-
| true -> "// tslint:disable-next-line:class-name\n"
361-
| false -> "")
362-
^ docString ^ "export abstract class " ^ resolvedTypeName ^ typeParamsString
357+
docString ^ "export abstract class " ^ resolvedTypeName ^ typeParamsString
363358
^ " { protected opaque!: " ^ typeOfOpaqueField
364359
^ " }; /* simulate opaque types */" ^ exportNameAs
365360
|> Emitters.export ~emitters
366361
else
367362
(if isInterface && config.exportInterfaces then
368363
docString ^ "export interface " ^ resolvedTypeName ^ typeParamsString ^ " "
369364
else
370-
"// tslint:disable-next-line:interface-over-type-literal\n" ^ docString
371-
^ "export type " ^ resolvedTypeName ^ typeParamsString ^ " = ")
365+
docString ^ "export type " ^ resolvedTypeName ^ typeParamsString ^ " = ")
372366
^ (match type_ with
373367
| _ -> type_ |> typeToString ~config ~typeNameIsInterface)
374368
^ ";" ^ exportNameAs
@@ -386,11 +380,6 @@ let emitImportValueAsEarly ~emitters ~name ~nameAs importPath =
386380

387381
let emitRequire ~importedValueOrComponent ~early ~emitters ~(config : Config.t)
388382
~moduleName importPath =
389-
let commentBeforeRequire =
390-
match importedValueOrComponent with
391-
| true -> "// tslint:disable-next-line:no-var-requires\n"
392-
| false -> "// @ts-ignore: Implicit any on import\n"
393-
in
394383
let importPath =
395384
match config.moduleResolution with
396385
| Node ->
@@ -402,15 +391,15 @@ let emitRequire ~importedValueOrComponent ~early ~emitters ~(config : Config.t)
402391
| ES6 when not importedValueOrComponent ->
403392
let moduleNameString = ModuleName.toString moduleName in
404393
(let es6ImportModule = moduleNameString ^ "__Es6Import" in
405-
commentBeforeRequire ^ "import * as " ^ es6ImportModule ^ " from '"
394+
"import * as " ^ es6ImportModule ^ " from '"
406395
^ (importPath |> ImportPath.emit)
407396
^ "';\n" ^ "const " ^ moduleNameString ^ ": any = " ^ es6ImportModule ^ ";")
408397
|> (match early with
409398
| true -> Emitters.requireEarly
410399
| false -> Emitters.require)
411400
~emitters
412401
| _ ->
413-
commentBeforeRequire ^ "const "
402+
"const "
414403
^ ModuleName.toString moduleName
415404
^ " = require('"
416405
^ (importPath |> ImportPath.emit)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"extends": [
3-
"react-app",
3+
"eslint:recommended",
44
"plugin:@typescript-eslint/recommended"
55
],
66
"parser": "@typescript-eslint/parser",
77
"plugins": ["@typescript-eslint"],
8-
"ignorePatterns": ["src/**/*.bs.js", "src/**/*.tsx", "src/MyMath.ts"]
9-
}
8+
"ignorePatterns": ["src/**/*.bs.js"],
9+
"root": true
10+
}

jscomp/gentype_tests/typescript-react-example/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test:
44
npm install
55
npm run build
66
npm run tsc
7+
npm run lint
78

89
clean:
910
rm -rf node_modules lib src/*.bs.js src/*.gen.tsx

0 commit comments

Comments
 (0)