This directory contains custom eslint rules for polygerrit.
This rule must be used only for .ts
files. The rule ensures that:
// Correct imports import './file1'; // relative path import '../abc/file2'; // relative path import 'module_name/xyz'; // import from the module_name // Incorrect imports import '/usr/home/file3'; // absolute path
// Correct imports import './file1'; // relative path without extension import data from 'module_name/file2.json'; // file in a module, can be anything // Incorrect imports import './file1.js'; // relative path with extension
.js
and .d.ts
files both exists (only for a relative import path):Example:
polygerrit-ui/app |- ex.ts |- abc |- correct_ts.ts |- correct_js.js |- correct_js.d.ts |- incorrect_1.js |- incorrect_2.d.ts
// The ex.ts file: // Correct imports import {x} from './abc/correct_js'; // correct_js.js and correct_js.d.ts exist import {x} from './abc/correct_ts'; // import from .ts - d.ts is not required // Incorrect imports import {x} from './abc/incorrect_1'; // incorrect_1.d.ts doesn't exist import {x} from './abc/incorrect_2'; // incorrect_2.js doesn't exist
To fix the last two imports 2 files must be added: incorrect_1.d.ts
and incorrect_2.js
.
Enforce correct usage of goog.declareModuleId:
.js
files which have associated .d.ts
files./usr/home/gerrit/polygerrit-ui/app/elements/shared/x/y.js
-> elements/shared/x/y.js
.js
extension and replace all /
with .
: elements/shared/x/y.js
-> elements.shared.x.y
polygerrit.
prefix: elements.shared.x.y
-> polygerrit.elements.shared.x.y
The last string is a module name.Example:
// polygerrit-ui/app/elements/shared/x/y.js goog.declareModuleId('polygerrit.elements.shared.x.y');