Skip to content

ESLint 9 #167

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

8 changes: 0 additions & 8 deletions .eslintrc

This file was deleted.

41 changes: 17 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [22]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Get Yarn cache directory
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'

- name: Use Yarn cache
uses: actions/cache@v4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Install dependencies
run: yarn install --prefer-offline --frozen-lockfile
- name: Test
run: pnpm test

- name: Test
run: yarn run test
- name: Lint
run: pnpm lint

- name: Lint
run: yarn run lint

- name: Build
run: yarn run build
- name: Build
run: pnpm build
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4

- name: Install dependencies
run: yarn install --frozen-lockfile
run: pnpm install --frozen-lockfile

- name: Build packages
run: yarn build
run: pnpm build

- name: PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn run changeset version
publish: yarn run changeset publish
version: pnpm changeset version
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30 changes: 23 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
.DS_Store
coverage
lib
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
npm-debug.log
package-lock.json
reports
yarn-error.log
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
npm-debug.log
/src
/reports
yarn-error.log
/.vscode
/docs
/.github
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v23.10.0
25 changes: 25 additions & 0 deletions __tests__/__util__/languageOptionsMapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { RuleTester } from 'eslint';
import deepmerge from 'deepmerge';

const defaultLanguageOptions = {
ecmaVersion: 2020,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
};

const languageOptionsMapper = (
testCase: RuleTester.ValidTestCase | RuleTester.InvalidTestCase,
) => ({
...testCase,
errors: (<RuleTester.InvalidTestCase>testCase).errors,
options: testCase.options ?? [],
languageOptions: deepmerge(
defaultLanguageOptions,
testCase.languageOptions ?? {},
),
});

export default languageOptionsMapper;
25 changes: 0 additions & 25 deletions __tests__/__util__/parserOptionsMapper.js

This file was deleted.

33 changes: 0 additions & 33 deletions __tests__/__util__/ruleOptionsMapperFactory.js

This file was deleted.

44 changes: 0 additions & 44 deletions __tests__/index-test.js

This file was deleted.

46 changes: 46 additions & 0 deletions __tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import plugin from '../src';
import type { Rule } from 'eslint';

const rules = import.meta.glob<true, string, { default: Rule.RuleModule }>(
'../src/rules/*.ts',
{ eager: true },
);

describe('all rule files should be exported by the plugin', () => {
it.each(Object.entries(rules))(
`exports %s`,
(rulePath, { default: ruleModule }) => {
const ruleName = rulePath.split('/').at(-1)?.replace('.ts', '');
expect(plugin.rules[ruleName as keyof typeof plugin.rules]).toEqual(
ruleModule,
);
},
);
});

describe('configs', () => {
it.each(['basic', 'ios', 'android', 'all'])(
`exports a %s config`,
(config) => {
expect(
plugin.configs[config as keyof typeof plugin.configs],
).toBeTruthy();
},
);
});

describe('schemas', () => {
it.each(
Object.entries(rules).filter(([filename]) => !filename.includes('index')),
)(
`%s exports a schema with type object`,
async (_, { default: ruleModule }) => {
const schema =
ruleModule.meta &&
ruleModule.meta.schema &&
(ruleModule.meta.schema as { type: string }[])[0];

expect((schema as { type: string }).type).toBe('object');
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// -----------------------------------------------------------------------------

import { RuleTester } from 'eslint';
import parserOptionsMapper from '../../__util__/parserOptionsMapper';
import languageOptionsMapper from '../../__util__/languageOptionsMapper';
import rule from '../../../src/rules/has-accessibility-hint';

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -39,13 +39,13 @@ ruleTester.run('has-accessibility-hint', rule, {
accessibilityHint="Navigates to the previous screen"
/>`,
},
].map(parserOptionsMapper),
].map(languageOptionsMapper),
invalid: [
{
code: `<TouchableOpacity
accessibilityLabel="Go back"
/>`,
errors: [expectedError],
},
].map(parserOptionsMapper),
].map(languageOptionsMapper),
});
Loading