Git Product home page Git Product logo

ios-scriptable-types's People

Contributors

343max avatar au5ton avatar dependabot[bot] avatar jasperhartong avatar jsejcksn avatar schl3ck avatar wilt00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ios-scriptable-types's Issues

executing eslint brings error

I download the example directory and tried running the command npx eslint . but there I'm getting the following error:
/scriptable/Welcome to Scriptable.js
57:18 error Parsing error: Unexpected token req

Is it not possible to use your files for eslint directly?

ESLint ignores uninitialized vars when using @scriptable-ios/eslint-config

When I added the ESLint config to my project, ESLint stopped detecting uninitialized variables.

My Scriptable folder looks like this:

Scriptable Folder
├──jsconfig.json
├──package.json
├──Script.js
└──...

jsconfig.json

{
  "compilerOptions": {
    "lib": ["ES2021"],
    "moduleDetection": "force"
  }
}

package.json

{
  "name": "scriptable",
  "version": "1.0.0",
  "eslintConfig": {
    "extends": "@scriptable-ios",
    "rules": {
      "no-unused-vars": "warn"
    },
    "parserOptions": { // workaround for top level await
      "ecmaVersion": "latest",
      "sourceType": "module"
    }
  },
  "devDependencies": {
    "@scriptable-ios/eslint-config": "latest",
    "@types/scriptable-ios": "latest",
    "eslint": "latest"
  }
}

There still is IntelliSense for Scriptable API, unused-vars, ... but missing errors for uninitialized vars.

Incorrect typings for Reminder attributes

Hey, love the project! I finally switched over to your library after having maintained my own version for years.

I know this issue is not your fault, since these typings are automatically generated from the docs, but though I'd flag it anyway.

notes, dueDate, and completionDate can all be falsy, and are by default. You can confirm this by running the following code in Scriptable:

const r = new Reminder();
console.log(JSON.stringify({
  notes: String(r.notes),
  dueDate: String(r.dueDate),
  completionDate: String(r.completionDate)
}, null, 2));

Which results in this:

{
  "notes": "undefined",
  "dueDate": "null",
  "completionDate": "null"
}

But your package, and the Scriptable docs, show all those values as never being falsy.

I've fixed this in my own codebase w/ the following type declaration:

declare class AdjustedReminder extends Reminder {
  notes?: string;
  dueDate?: Date;
  completionDate?: Date;
}

And then I just use AdjustedReminder anywhere I'd otherwise use Reminder (as a type).

Typescript using built-in Request instead of Scriptable Request

The Issue

I am currently trying to code a Scriptable script with typescript, webpack, and schl3ck/ios-scriptable-types. However, as I tried to create a new Request, Typescript IntelliSense used the node.js Request instead of the Scriptable Request for linting.

This is not specifically an issue with this repo, but rather a problem with how VSCode IntelliSense handles the naming conflict of the built-in node.js Request and the Scriptable Request. I am not asking for a fix by this repo owner (because I think there is none), but rather if you know how to fix this issue.

I can also just // @ts-ignore the line, but this will give me an any type, which I don't want to do.

Files

./.eslintrc

{
  "root": true,
  "env": {
    "es2022": true,
    "jest": true
  },
  "parser": "@typescript-eslint/parser",
  "plugins": ["@typescript-eslint"],
  "extends": ["plugin:@typescript-eslint/recommended", "@scriptable-ios"],
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "rules": {}
}

./jsconfig.json

{
  "compilerOptions": {
    "lib": ["ES2021"],
    "moduleDetection": "force"
  }
}

./tsconfig.json

{
  "compilerOptions": {
    "module": "CommonJS",
    "target": "es2017",
    "outDir": "./dist",
    "noImplicitAny": true,
    "skipLibCheck": true
  },
  "include": ["./src/package/**/*"]
}

./package.json

{
  "name": "spm-package",
  "type": "module",
  "scripts": {
    "build": "npx webpack --mode=production --node-env=production",
    "watch": "npx webpack --mode=development --node-env=development --watch",
    "test": "npx jest"
  },
  "devDependencies": {
    "@scriptable-ios/eslint-config": "^1.7.0",
    "@types/scriptable-ios": "latest",
    "@typescript-eslint/eslint-plugin": "^5.46.0",
    "@typescript-eslint/parser": "^5.46.0",
    "eslint": "latest",
    "eslint-webpack-plugin": "^3.2.0",
    "jest": "^29.3.1",
    "ts-loader": "^9.4.2",
    "typescript": "^4.9.4",
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.1"
  }
}

./src/package/Package.ts

export default class Package {
  author: string;
  name: string;
  version: string;

  description: string;
  fileData: string | null;

  constructor(author: string, name: string, version: string) {
    this.author = author;
    this.name = name;
    this.version = version;
  }

  async fetchPackageInfo() {
    const url = ``;
    const data = await new Request(url).loadJSON();
  }
}

Output by IntelliSense

image

The Request type used by IntelliSense is located at
/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/lib.dom.d.ts

[Discuss] Next steps for publishing

Hey—I think you've done some valuable work here!

From the readme:

I don't know how to publish this. I've thought about DefinitlyTyped. But then you need to have npm and a node_modules folder in the working dorectory. Or should I make a VisualStudio Code Extension? (But that would take some time)

If you have any idea, just open an issue.

I see a lot of benefit from making the content of this project consumable as modules.

A listing in DefinitelyTyped as well as an ESLint shareable config would provide complementary functionality.

I propose the namespace scriptable-ios so it could be

@types/scriptable-ios and @scriptable-ios/eslint-config. I have created a pull request with an example, which you can explore.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.