Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint #301

Merged
merged 3 commits into from
Feb 6, 2024
Merged

lint #301

merged 3 commits into from
Feb 6, 2024

Conversation

justinmk
Copy link
Member

@justinmk justinmk commented Feb 2, 2024

Add more lint rules, including rules from https://github.com/sindresorhus/eslint-plugin-unicorn

Fixed with:

./node_modules/.bin/eslint --format=unix packages/*/src/**/*.ts packages/*/src/*.ts --fix

Fix #266

@@ -44,13 +52,50 @@ module.exports = {
'import/extensions': 'off',
'import/prefer-default-export': 'off',

'@typescript-eslint/no-namespace': 'error',
// TODO: '@typescript-eslint/no-floating-promises': 'error', // Promises must catch errors or be awaited.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a useful one but should wait until after a release, since it's a bit risky.

fixed with:

    ./node_modules/.bin/eslint --format=unix packages/*/src/**/*.ts packages/*/src/*.ts --fix

fix #266
Problem:
Can't use newer JS features like `Array.at()`

Solution:
- Polyfill to es2015, so we can use esnext features in our `.ts` code.
- Set `lib=esnext`. This is still compatible with older node.js, because
  `target=es2015`.
- our CI currently tests node.js 14
- our .babelrc.js targets node.js 8
We must disable eslint rules that require new javascript features in
test files, because test files are not currently compiled by `tsc`.

TODO: doesn't look like babel is configured to run on the "neovim"
package. I tried this:

    M packages/neovim/package.json
    @@ -72,7 +72,7 @@
         "test-staged": "npm test --bail --no-cache --findRelatedTests",
         "test-missing-apis": "npm run build && node scripts/findMissingApi",
         "precommit": "lint-staged",
    -    "build": "tsc --pretty",
    +    "build": "tsc --pretty && babel lib --out-dir lib",
         "dev": "npm run build --watch true"
       },
       "jest": {
    M packages/neovim/src/utils/getNvimFromEnv.ts
    @@ -149,6 +149,8 @@ export function getNvimFromEnv(
       const paths = process.env.PATH.split(delimiter);
       const pathLength = paths.length;
       const matches = new Array<NvimVersion>();
    +  const foo = matches.at(-1);
    +  console.log(foo); // test
       const unmatchedVersions = new Array<NvimVersion>();
       const errors = new Array<GetNvimFromEnvError>();
       for (let i = 0; i !== pathLength; i = i + 1) {

Babel didn't translate the file to the desired node.js 8 compatible
syntax (it should replace `matches.at()` with `matches[…]`).
@justinmk justinmk merged commit a24d608 into master Feb 6, 2024
10 of 11 checks passed
@justinmk justinmk deleted the lint branch February 6, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

more lint checks
1 participant