Create global constants file (#273)

* Create global constants file

* Update constants import for all files

* Tweak project style guides

Change printWidth from 80, recommended project widths were at 100/120 so I choose 120.

Also while I'm doing it, tweak the EndOfLine setting to prevent VS Code from going ham on LF/CRLF sets.

* Remove the ESLint ignore lines in PR

And other import whitespace near it

* SNAKE_CASE constants instead of camelCase
This commit is contained in:
Soitora 2020-07-29 19:36:55 +02:00 committed by GitHub
parent e15291d180
commit 6a660e98fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 24 additions and 34 deletions

View File

@ -23,7 +23,9 @@
"markdown" "markdown"
], ],
"rules": { "rules": {
"prettier/prettier": "error", "prettier/prettier": ["error", {
"endOfLine":"auto"
}],
"import/no-unresolved": [ "import/no-unresolved": [
2, 2,
{ "ignore": ["^@"] } { "ignore": ["^@"] }

View File

@ -1,7 +1,8 @@
{ {
"tabWidth": 4, "tabWidth": 4,
"useTabs": true, "useTabs": true,
"printWidth": 120,
"trailingComma": "es5", "trailingComma": "es5",
"bracketSpacing": true, "bracketSpacing": true,
"endOfLine": "lf" "endOfLine": "auto"
} }

View File

@ -11,11 +11,7 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import { GITHUB_LATEST_API, GITHUB_LATEST_RELEASE, KANADE_LATEST } from "../constants";
const RELEASE_URL =
"https://api.github.com/repos/inorichi/tachiyomi/releases/latest";
const PREVIEW_URL = "https://tachiyomi.kanade.eu/latest";
export default { export default {
props: { props: {
@ -53,7 +49,7 @@ export default {
}, },
async mounted() { async mounted() {
const { data } = await axios.get(RELEASE_URL); const { data } = await axios.get(GITHUB_LATEST_API);
// Maybe eventually some release has more than the apk in assets. // Maybe eventually some release has more than the apk in assets.
const apkAsset = data.assets.find((a) => a.name.includes(".apk")); const apkAsset = data.assets.find((a) => a.name.includes(".apk"));
// Set the values. // Set the values.
@ -85,7 +81,7 @@ export default {
window.location.assign( window.location.assign(
this.$props.downloadStableUrl || this.$props.downloadStableUrl ||
this.$data.browserDownloadUrl || this.$data.browserDownloadUrl ||
RELEASE_URL GITHUB_LATEST_RELEASE
); );
window.ga( window.ga(
"send", "send",
@ -116,7 +112,7 @@ export default {
}, },
}); });
window.location.assign( window.location.assign(
this.$props.downloadPreviewUrl || PREVIEW_URL this.$props.downloadPreviewUrl || KANADE_LATEST
); );
window.ga( window.ga(
"send", "send",

View File

@ -47,9 +47,7 @@ import axios from "axios";
import groupBy from "lodash.groupby"; import groupBy from "lodash.groupby";
import sortBy from "lodash.sortby"; import sortBy from "lodash.sortby";
import ISO6391 from "iso-639-1"; import ISO6391 from "iso-639-1";
import { GITHUB_EXTENSION_JSON } from "../constants";
const EXTENSION_JSON =
"https://raw.githubusercontent.com/inorichi/tachiyomi-extensions/repo/index.json";
export default { export default {
data() { data() {
@ -59,7 +57,7 @@ export default {
}, },
async beforeMount() { async beforeMount() {
const { data } = await axios.get(EXTENSION_JSON); const { data } = await axios.get(GITHUB_EXTENSION_JSON);
const values = Object.values(groupBy(data, "lang")); const values = Object.values(groupBy(data, "lang"));
this.$data.extensions = sortBy(values, [ this.$data.extensions = sortBy(values, [
(g) => this.langName(g[0].lang), (g) => this.langName(g[0].lang),

View File

@ -5,9 +5,7 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import marked from "marked"; import marked from "marked";
import { GITHUB_LATEST_API } from "../constants";
const RELEASE_URL =
"https://api.github.com/repos/inorichi/tachiyomi/releases/latest";
export default { export default {
data() { data() {
@ -17,7 +15,7 @@ export default {
}, },
async mounted() { async mounted() {
const { data } = await axios.get(RELEASE_URL); const { data } = await axios.get(GITHUB_LATEST_API);
this.$data.releaseNotes = marked(data.body); this.$data.releaseNotes = marked(data.body);
}, },
}; };

View File

@ -11,9 +11,7 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import { GITHUB_LATEST_API } from "../constants";
const RELEASE_URL =
"https://api.github.com/repos/inorichi/tachiyomi/releases/latest";
export default { export default {
props: { props: {
@ -29,7 +27,7 @@ export default {
}, },
async mounted() { async mounted() {
const { data } = await axios.get(RELEASE_URL); const { data } = await axios.get(GITHUB_LATEST_API);
// Set the values. // Set the values.
this.$data.tagName = data.tag_name; this.$data.tagName = data.tag_name;
}, },

View File

@ -0,0 +1,4 @@
export const GITHUB_EXTENSION_JSON = "https://raw.githubusercontent.com/inorichi/tachiyomi-extensions/repo/index.json";
export const GITHUB_LATEST_RELEASE = "https://github.com/inorichi/tachiyomi/releases/latest";
export const GITHUB_LATEST_API = "https://api.github.com/repos/inorichi/tachiyomi/releases/latest";
export const KANADE_LATEST = "https://tachiyomi.kanade.eu/latest";

View File

@ -80,16 +80,9 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import CloudDownloadIcon from "vue-material-design-icons/CloudDownload.vue"; import CloudDownloadIcon from "vue-material-design-icons/CloudDownload.vue";
import BookOpenVariantIcon from "vue-material-design-icons/BookOpenVariant.vue"; import BookOpenVariantIcon from "vue-material-design-icons/BookOpenVariant.vue";
import { GITHUB_LATEST_API, GITHUB_LATEST_RELEASE, KANADE_LATEST } from "../../constants";
const RELEASE_URL =
"https://api.github.com/repos/inorichi/tachiyomi/releases/latest";
const LATEST_RELEASE = "https://github.com/inorichi/tachiyomi/releases/latest";
const PREVIEW_URL = "https://tachiyomi.kanade.eu/latest";
export default { export default {
name: "Home", name: "Home",
@ -126,7 +119,7 @@ export default {
}, },
async mounted() { async mounted() {
const { data } = await axios.get(RELEASE_URL); const { data } = await axios.get(GITHUB_LATEST_API);
const apkAsset = data.assets.find((a) => a.name.includes(".apk")); const apkAsset = data.assets.find((a) => a.name.includes(".apk"));
this.$data.tagName = data.tag_name; this.$data.tagName = data.tag_name;
this.$data.browserDownloadUrl = apkAsset.browser_download_url; this.$data.browserDownloadUrl = apkAsset.browser_download_url;
@ -194,7 +187,7 @@ export default {
}, },
}); });
window.location.assign( window.location.assign(
this.$data.browserDownloadUrl || LATEST_RELEASE this.$data.browserDownloadUrl || GITHUB_LATEST_RELEASE
); );
window.ga( window.ga(
"send", "send",
@ -263,7 +256,7 @@ export default {
"animate__animated animate__faster animate__zoomOut", "animate__animated animate__faster animate__zoomOut",
}, },
}); });
window.location.assign(PREVIEW_URL); window.location.assign(KANADE_LATEST);
window.ga( window.ga(
"send", "send",
"event", "event",