Skip to content

Latest commit

 

History

History
87 lines (54 loc) · 4.39 KB

CONTRIBUTING.md

File metadata and controls

87 lines (54 loc) · 4.39 KB

Contributing to Saladict

👍🎉 First off, thanks for taking the time to contribute! 🎉👍

How to Contribute

⚠️ Unless it is a small hot fix, before you write any code and get your hands dirty, please open an issue or make a WIP pull request to elaborate what you are trying to do and how you are going to implement it. Just to make sure we are on the same page and nobody's time and effort are wasted.

How to get started

Clone the repo and run yarn install.

UI Tweaking

Run yarn start --main=[entry id] to view a certain entry with WDS in a fake WebExtension environment.

Entry ids are generally directory names in src.

index.[html/js(x)/ts(x) in [entry id]/__fake__ has higher priority.

Testing

Run yarn test to run Jest. Supports all the Jest options.

Building

Run yarn devbuild to start a quick build without compression.

Run yarn build to start a full build.

Toggle:

  • --notypecheck: Skip TypeScript full check.
  • --analyze: Show detailed Webpack bundle analyzer.

Releasing

Run yarn release to bump version and generate CHANGELOG.

Zipball

Run yarn zip to pack zibballs to ./dist/.

How to add a dictionary

  1. Register the dictionary in app config so that TypeScript generates the correct typings. Dict ID MUST follow alphabetical order.
  2. Create a directory at src/components/dictionaries/, with the name of the dict ID.
  3. Use any existing dictionary as guidance, e.g. Bing. Copy files to the new directory.
  4. Replace the favicon with a new LOGO.
  5. Update _locales.json with the new dictionary name. Add locales for options, if any.
  6. engine.ts MUST export at least two functions:
    1. getSrcPage function which is responsible for generating source page url base on search text and app config. Source page url is opened when user clicks the dictionary title.
    2. search function which is responsible for fetching, parsing and returning dictionary results. See the typings for more detail.
      • Extracting information from a webpage MUST use helper functions in ../helpers.ts for data cleansing.
      • If the dictionary supports pronunciation:
        1. Register the ID at config.autopron.
        2. Include an audio field in the object which search engine returns.
    3. Other exported functions can be called from View.tsx via DictEngineMethod message channel, see src/typings/message for typing details (also don't use the native sendMessage function, import { message } from '@/_helpers/browser-api').
  7. Search result will ultimately be passed to a React PureComponent in View.tsx, which SHOULD be a dumb component that renders the result accordingly.
  8. Scope the styles in _style.scss following ECSS-ish naming convention.

Add Testing

  1. Add response samples at test/specs/components/dictionaries/[dictID]/response.
  2. Add engine.spec.ts to test the engine.

Develop the dictionary UI live

  1. Intercept ajax calls in config/fake-env/fake-ajax.js. Use the testing response samples.
  2. Edit src/components/__fake__/index.tsx.
  3. Run yarn start --main=components.

Code Style

This project follows the TypeScript variation of Standard JavaScript code style.

If you are using IDEs like VSCode, make sure TSLint related plugins are installed. Or you can just run building command to perform a TypeScript full check.

Commit Style

This project follows conventional commit style.

You can run yarn commit and follow the instructions, or use vscode-commitizen extension in VSCode.