Skip to content

Commit

Permalink
Convert codebase to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
GillesDebunne committed Aug 23, 2020
1 parent df31219 commit 6c0dd93
Show file tree
Hide file tree
Showing 97 changed files with 11,638 additions and 4,141 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/types/intl.d.ts
src/luxon.d.ts
36 changes: 25 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
module.exports = {
parser: "babel-eslint",
extends: ["standard", "plugin:prettier/recommended"],
plugins: ["import", "prettier", "babel"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
ecmaVersion: "2020",
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
],
plugins: ["import", "prettier", "@typescript-eslint"],
rules: {
"linebreak-style": "off",
"one-var": "off",
"spaced-comment": ["error", "always", { exceptions: ["-"] }],
"valid-jsdoc": "off",
"prettier/prettier": "warn",
"prefer-const": ["error", { destructuring: "all" }]
},
parserOptions: {
ecmaVersion: "2020"
"prefer-const": ["error", { destructuring: "all" }],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/prefer-includes": "off", // Only available in es2016
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
],
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-use-before-define": "off",
},
env: {
es6: true
}
es6: true,
},
};
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
node_modules/
.tern-port
/build
build/
transpiled/
#*
.#*
coverage/
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sudo: true
services:
- docker
- docker
before_install:
- docker pull icambron/luxon
- ./docker/npm install
script:
- ./docker/npm run build
- ./docker/npm run tsc
- ./docker/npm run lint
- ./docker/npm run test
- ./docker/npm run docs
- ./docker/npm run check-doc-coverage
- bash <(curl -s https://codecov.io/bash)

8 changes: 5 additions & 3 deletions benchmarks/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ suite
})
.add("DateTime.fromFormat with zone", () => {
DateTime.fromFormat("1982/05/25 09:10:11.445", "yyyy/MM/dd HH:mm:ss.SSS", {
zone: "America/Los_Angeles"
zone: "America/Los_Angeles",
});
})
.add("DateTime#setZone", () => {
Expand Down Expand Up @@ -57,11 +57,13 @@ suite
.add("DateTime#toRelativeCalendar", () => {
dt.toRelativeCalendar({ base: DateTime.local(), locale: "fi" });
})
.on("cycle", event => {
.on("cycle", (event) => {
// eslint-disable-next-line no-undef
console.log(String(event.target));
})
// eslint-disable-next-line func-names
.on("complete", function() {
.on("complete", function () {
// eslint-disable-next-line no-undef
console.log("Fastest is " + this.filter("fastest").map("name"));
})
.run();
2 changes: 1 addition & 1 deletion docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const manualFiles = [
const excludeIrrelevant = ["luxon\\.js", "luxonFilled\\.js", "impl/.*\\.js"];

module.exports = {
source: "./src",
source: "./transpiled/src",
destination: "./build/docs",
excludes: excludeIrrelevant,
plugins: [
Expand Down
10 changes: 9 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ module.exports = {
testEnvironment: "node",
roots: ["test", "src"],
coverageDirectory: "build/coverage",
collectCoverageFrom: ["src/**/*.js", "!src/zone.js", "!src/luxonFilled.js"]
collectCoverageFrom: [
"src/**/*.ts",
"!src/zone.ts",
"!src/luxonFilled.ts",
"!src/luxon.d.ts",
"!src/types/intl.d.ts"
],
preset: "ts-jest",
moduleFileExtensions: ["ts", "js"]
};
Loading

0 comments on commit 6c0dd93

Please sign in to comment.