.eslintrc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"extends": [
"eslint:recommended",
"prettier"
],
"plugins": [
"angular",
"html",
"unused-imports",
"@typescript-eslint",
"oppia"
],
"overrides": [
{
// We exclude test files from dependency injection format checks because
// they are never minified. Also, we exclude no-loss-of-precision check as
// it is only relevant for non-test files, since when running
// frontend tests there is no loss of precision.
"files": ["*Spec.js", "*Spec.ts", "*.spec.ts"],
"rules": {
"angular/di": "off",
"no-loss-of-precision": "off"
}
},
{
"files": ["*.js", "*.ts"],
"excludedFiles": [
"complete.spec.ts",
"student.spec.ts",
"teacher.spec.ts"
],
"rules": {
"oppia/no-to-throw": "error"
}
},
{
// We only run the e2e action checks on end-to-end test files, and
// we exclude files that we haven't fixed yet.
"files": [
"core/tests/webdriverio/*.js",
"core/tests/webdriverio_utils/*.js",
"core/tests/webdriverio_desktop/*.js"
],
"excludedFiles": [
"ClassroomPage.js",
"DeleteAccountPage.js",
"ExplorationEditorHistoryTab.js",
"ExplorationEditorMainTab.js",
"ExplorationEditorPage.js",
"ExplorationEditorSettingsTab.js",
"ExplorationEditorStatsTab.js",
"ExplorationEditorTranslationTab.js",
"GetStartedPage.js",
"LearnerDashboardPage.js",
"LibraryPage.js",
"ProfilePage.js",
"SkillEditorPage.js",
"StoryEditorPage.js",
"SubscriptionDashboardPage.js",
"ThanksPage.js",
"TopicAndStoryViewerPage.js",
"TopicEditorPage.js",
"TopicsAndSkillsDashboardPage.js",
"action.js",
"forms.js",
"general.js",
"users.js",
"waitFor.js",
"workflow.js",
"additionalEditorFeatures.js",
"additionalPlayerFeatures.js",
"adminTabFeatures.js",
"classroomPage.js",
"classroomPageFileUploadFeatures.js",
"collections.js",
"contributorDashboard.js",
"coreEditorAndPlayerFeatures.js",
"creatorDashboard.js",
"embedding.js",
"explorationFeedbackTab.js",
"explorationHistoryTab.js",
"explorationImprovementsTab.js",
"explorationStatisticsTab.js",
"explorationTranslationTab.js",
"extensions.js",
"fileUploadExtensions.js",
"learnerDashboard.js",
"navigation.js",
"playVoiceovers.js",
"preferences.js",
"profileFeatures.js",
"publicationAndLibrary.js",
"skillEditor.js",
"topicAndStoryEditor.js",
"topicAndStoryEditorFileUploadFeatures.js",
"topicAndStoryViewer.js",
"topicsAndSkillsDashboard.js",
"userJourneys.js",
"voiceoverUploadFeatures.js",
"wipeout.js",
"accessibility.js",
"learnerFlow.js",
"libraryFlow.js",
"profileMenuFlow.js",
"excludedForTesting.js"
],
"rules": {
"oppia/e2e-action": "error"
}
},
{
// We only run the e2e practices checks on webdriverio
// end-to-end test files.
"files": [
"core/tests/webdriverio/*.js",
"core/tests/webdriverio_utils/*.js",
"core/tests/webdriverio_desktop/*.js"
],
"rules": {
"oppia/e2e-practices": "error"
}
},
{
// We exclude spec files to the no-testonly check
"files": ["*spec.js", "*spec.ts"],
"rules": {
"oppia/no-testonly": "off"
}
},
{
"files": ["*.js", "*.ts"],
"excludedFiles": [
"Polyfills.ts",
"ck-editor-copy-content.service.spec.ts",
"unit-test-utils.ajs.ts",
"mathjax.directive.ts",
"math-expression-content-editor.component.ts",
"core/tests/*"
],
"rules": {
"oppia/no-inner-html": "error"
}
},
{
"files": ["*.js", "*.ts"],
"excludedFiles": [
"core/tests/**"
],
"rules": {
"oppia/no-relative-import": "error"
}
}
],
"rules": {
"oppia/constant-declaration": "error",
"oppia/comment-style": "error",
"oppia/disallow-flags": "error",
"oppia/disallow-httpclient": "error",
"oppia/disallow-angularjs-properties": "error",
"oppia/import-lodash": "error",
"oppia/no-multiple-component": "error",
"oppia/no-multiline-disable": "error",
"oppia/directive-scope": "error",
"oppia/no-testonly": "error",
"oppia/sorted-dependencies": "error",
"oppia/test-message-style": "error",
"oppia/dependency-checks": "error",
"oppia/no-test-blockers": "error",
"oppia/no-inject": "error",
"oppia/no-bypass-security-phrase": "error",
"angular/di": [
"error",
"array"
],
"angular/di-unused": "error",
"angular/directive-restrict": [
"error",
{
"restrict": "E"
}
],
"angular/no-inline-template": [
"error",
{
"allowSimple": true
}
],
"array-bracket-spacing": [
"error",
"never"
],
"camelcase": [
"error",
{
"properties": "never"
}
],
"capitalized-comments": [
"error",
"always",
{
"ignorePattern": "disable-bad-pattern-check|fall-through",
"ignoreConsecutiveComments": true
}
],
"curly": [
"error",
"all"
],
"dot-notation": [
"error",
{
"allowKeywords": true
}
],
"eol-last":[
"error",
"always"
],
"eqeqeq": [
"error",
"always"
],
"func-style": [
"error",
"expression"
],
"key-spacing": "error",
"no-compare-neg": "off",
"no-console": [
"error",
{
"allow": [
"error",
"warn"
]
}
],
"no-constant-condition": [
"off"
],
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-multi-spaces": [
"error"
],
"no-multi-str": [
"error"
],
"no-prototype-builtins": "off",
"no-redeclare": [
"off"
],
"no-restricted-globals": [
"error", "addEventListener", "blur", "close", "closed", "confirm",
"defaultStatus", "event", "external", "defaultstatus", "find", "focus",
"frameElement", "frames", "history", "innerHeight", "innerWidth",
"length", "location", "locationbar", "menubar", "moveBy", "moveTo",
"name", "onblur", "onerror", "onfocus", "onload", "onresize", "onunload",
"open", "opener", "opera", "outerHeight", "outerWidth", "pageXOffset",
"pageYOffset", "parent", "print", "removeEventListener", "resizeBy",
"resizeTo", "screen", "screenLeft", "screenTop", "screenX", "screenY",
"scroll", "scrollbars", "scrollBy", "scrollTo", "scrollX", "scrollY",
"self", "sessionStorage", "status", "statusbar", "stop",
"toolbar", "top"],
"no-tabs": "error",
"no-useless-escape": "off",
"no-whitespace-before-property": "error",
"no-trailing-spaces": [
"error"
],
"no-undef": [
"off"
],
"no-throw-literal": "error",
"no-unused-vars": [
"off"
],
"one-var": [
"off"
],
"padded-blocks": [
"error",
"never"
],
"quotes": [
"off"
],
// The following must be off so that we can enable
// "@typescript-eslint/semi", which checks semicolons in TS files.
"semi": "off",
// The following must be off so that we can enable
// "@typescript-eslint/no-extra-semi".
"no-extra-semi": "off",
"lines-between-class-members": "off",
"semi-spacing": "error",
"space-before-blocks": [
"error",
"always"
],
"spaced-comment": [
"error",
"always"
],
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": [
"error"
],
"space-unary-ops": [
"error",
{
"words": true,
"nonwords": false
}
],
"switch-colon-spacing": [
"error",
{
"after": true,
"before": false
}
],
"unused-imports/no-unused-imports-ts": "error",
"@typescript-eslint/no-explicit-any": ["error"],
"@typescript-eslint/semi": ["error"],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"String": {
"message": "Use string instead.",
"fixWith": "string"
},
"Number": {
"message": "Use number instead.",
"fixWith": "number"
},
"Boolean": {
"message": "Use boolean instead.",
"fixWith": "boolean"
}
},
"extendDefaults": false
}
],
"@typescript-eslint/array-type": [
"error",
{
"default": "array"
}
],
"@typescript-eslint/consistent-type-assertions": ["error"],
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
"@typescript-eslint/no-non-null-assertion": ["error"],
"@typescript-eslint/no-non-null-asserted-optional-chain": ["error"],
"@typescript-eslint/prefer-namespace-keyword": ["error"],
"@typescript-eslint/triple-slash-reference": ["error"],
"@typescript-eslint/adjacent-overload-signatures": ["error"],
"@typescript-eslint/no-extra-non-null-assertion": ["error"],
"@typescript-eslint/no-misused-new": ["error"],
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "none",
"varsIgnorePattern": "^_$"
}
],
"@typescript-eslint/explicit-module-boundary-types": ["error"],
"@typescript-eslint/prefer-as-const": ["error"],
"@typescript-eslint/no-array-constructor": ["error"],
"@typescript-eslint/no-extra-semi": ["error"],
"@typescript-eslint/type-annotation-spacing": ["error"],
"wrap-iife": [
"error",
"any"
],
"@typescript-eslint/member-delimiter-style": ["error"],
"@typescript-eslint/method-signature-style": ["error"],
"@typescript-eslint/keyword-spacing": [
"error",
{
"before": true,
"after": true
}
],
"@typescript-eslint/comma-spacing": [
"error",
{
"before": false,
"after": true
}
],
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"no-dupe-class-members": "off",
"@typescript-eslint/no-dupe-class-members": ["error"],
"@typescript-eslint/no-namespace": ["error"]
}
}