mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
[HTML5] Enforce JavaScript style with eslint.
Applies to javascript files inside the platform library folder, the exposed Engine code, and any javascript files in modules. Files ending with ".externs.js" will be ignored, you can create a ".eslintignore" file to specify extra files to be ignored.
This commit is contained in:
parent
a82f70ea9f
commit
c38984d286
8
.github/workflows/static_checks.yml
vendored
8
.github/workflows/static_checks.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Azure repositories are not reliable, we need to prevent azure giving us packages.
|
||||
# Azure repositories are not reliable, we need to prevent Azure giving us packages.
|
||||
- name: Make apt sources.list use the default Ubuntu repositories
|
||||
run: |
|
||||
sudo rm -f /etc/apt/sources.list.d/*
|
||||
@ -33,6 +33,12 @@ jobs:
|
||||
run: |
|
||||
bash ./misc/scripts/black_format.sh
|
||||
|
||||
- name: JavaScript style checks via ESLint
|
||||
run: |
|
||||
cd platform/javascript
|
||||
npm ci
|
||||
npm run lint
|
||||
|
||||
- name: Documentation checks
|
||||
run: |
|
||||
doc/tools/makerst.py --dry-run doc/classes modules
|
||||
|
10
platform/javascript/.eslintrc.engine.js
Normal file
10
platform/javascript/.eslintrc.engine.js
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"./.eslintrc.js",
|
||||
],
|
||||
"globals": {
|
||||
"Godot": true,
|
||||
"Preloader": true,
|
||||
"Utils": true,
|
||||
},
|
||||
};
|
43
platform/javascript/.eslintrc.js
Normal file
43
platform/javascript/.eslintrc.js
Normal file
@ -0,0 +1,43 @@
|
||||
module.exports = {
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
},
|
||||
"extends": [
|
||||
"airbnb-base",
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
},
|
||||
"ignorePatterns": "*.externs.js",
|
||||
"rules": {
|
||||
"func-names": "off",
|
||||
// Use tabs for consistency with the C++ codebase.
|
||||
"indent": ["error", "tab"],
|
||||
"max-len": "off",
|
||||
"no-else-return": ["error", {allowElseIf: true}],
|
||||
"curly": ["error", "all"],
|
||||
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
|
||||
"no-bitwise": "off",
|
||||
"no-continue": "off",
|
||||
"no-self-assign": "off",
|
||||
"no-tabs": "off",
|
||||
"no-param-reassign": ["error", { "props": false }],
|
||||
"no-plusplus": "off",
|
||||
"no-unused-vars": ["error", { "args": "none" }],
|
||||
"prefer-destructuring": "off",
|
||||
"prefer-rest-params": "off",
|
||||
"prefer-spread": "off",
|
||||
"camelcase": "off",
|
||||
"no-underscore-dangle": "off",
|
||||
"max-classes-per-file": "off",
|
||||
"prefer-arrow-callback": "off",
|
||||
// Messes up with copyright headers in source files.
|
||||
"spaced-comment": "off",
|
||||
// Completely breaks emscripten libraries.
|
||||
"object-shorthand": "off",
|
||||
// Closure compiler (exported properties)
|
||||
"quote-props": ["error", "consistent"],
|
||||
"dot-notation": "off",
|
||||
}
|
||||
};
|
22
platform/javascript/.eslintrc.libs.js
Normal file
22
platform/javascript/.eslintrc.libs.js
Normal file
@ -0,0 +1,22 @@
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"./.eslintrc.js",
|
||||
],
|
||||
"globals": {
|
||||
"LibraryManager": true,
|
||||
"mergeInto": true,
|
||||
"autoAddDeps": true,
|
||||
"HEAP8": true,
|
||||
"HEAPU8": true,
|
||||
"HEAP32": true,
|
||||
"HEAPF32": true,
|
||||
"ERRNO_CODES": true,
|
||||
"FS": true,
|
||||
"IDBFS": true,
|
||||
"GodotOS": true,
|
||||
"GodotConfig": true,
|
||||
"GodotRuntime": true,
|
||||
"GodotFS": true,
|
||||
"IDHandler": true,
|
||||
},
|
||||
};
|
1605
platform/javascript/package-lock.json
generated
Normal file
1605
platform/javascript/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
platform/javascript/package.json
Normal file
24
platform/javascript/package.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "godot",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"description": "Linting setup for Godot's HTML5 platform code",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"lint": "npm run lint:engine && npm run lint:libs && npm run lint:modules",
|
||||
"lint:engine": "eslint \"js/engine/*.js\" --no-eslintrc -c .eslintrc.engine.js",
|
||||
"lint:libs": "eslint \"js/libs/*.js\" --no-eslintrc -c .eslintrc.libs.js",
|
||||
"lint:modules": "eslint \"../../modules/**/*.js\" --no-eslintrc -c .eslintrc.libs.js",
|
||||
"format": "npm run format:engine && npm run format:libs && npm run format:modules",
|
||||
"format:engine": "npm run lint:engine -- --fix",
|
||||
"format:libs": "npm run lint:libs -- --fix",
|
||||
"format:modules": "npm run lint:modules -- --fix"
|
||||
},
|
||||
"author": "Godot Engine contributors",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint": "^7.9.0",
|
||||
"eslint-config-airbnb-base": "^14.2.0",
|
||||
"eslint-plugin-import": "^2.22.0"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user