Skip to content

Commit

Permalink
added setup files
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Dec 16, 2023
1 parent 4e37107 commit 2af1c24
Show file tree
Hide file tree
Showing 11 changed files with 503 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .componentsignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[

]
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: lint

on:
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Check out repository
uses: actions/checkout@v3
- name: Load cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-lint-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Run linter
run: yarn run lint
11 changes: 11 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: push
on: [push]

jobs:
test:
# Run the tests in every case
uses: ./.github/workflows/test.yml

lint:
# Run the tests in every case
uses: ./.github/workflows/lint.yml
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: test

on:
workflow_call:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version:
- 18.x
- 20.x
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Ensure line endings are consistent
run: git config --global core.autocrlf input
- name: Check out repository
uses: actions/checkout@v3
- name: Load cache
uses: actions/cache@v2
with:
path: |
**/node_modules
.rdf-test-suite-cache
.rdf-test-suite-ldf-cache
key: ${{ runner.os }}-test-modules-${{ secrets.CACHE_VERSION }}-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Build project
run: yarn run build
- name: Run depcheck
run: yarn run depcheck
- name: Run browser-tests
run: yarn run test-browser
- name: Run tests
run: yarn run test-ci
- name: Submit coverage results
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.node-version }}
parallel: true

coveralls:
needs: test
runs-on: ubuntu-latest
steps:
- name: Consolidate test coverage from different jobs
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
9 changes: 9 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
"https://linkedsoftwaredependencies.org/bundles/npm/solid-aggregator/^0.0.0/components/context.jsonld"
],
"@id": "urn:solid-aggregator:endpoint",
"@type": "Endpoint",
"test": "test"
}
26 changes: 26 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const antfu = require('@antfu/eslint-config');
const generalConfig = require('./eslint/general');
const testConfig = require('./eslint/test');
const typedConfig = require('./eslint/typed');
const unicornConfig = require('./eslint/unicorn');

module.exports = antfu.default(
{
ignores: [ 'lib/**/*.js', 'lib/**/*.d.ts', '**/*.md' ],
},
generalConfig,
unicornConfig,
typedConfig,
testConfig,
{
// JSON rules
files: [ '**/*.json' ],
rules: {
'jsonc/array-bracket-spacing': [ 'error', 'always', {
singleValue: true,
objectsInArrays: false,
arraysInArrays: false,
}],
},
},
);
114 changes: 114 additions & 0 deletions eslint/general.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
module.exports = {
rules: {
'antfu/consistent-list-newline': 'error',

'arrow-body-style': [ 'error', 'as-needed', { requireReturnForObjectLiteral: false }],
'capitalized-comments': [ 'error', 'always', { ignoreConsecutiveComments: true }],
curly: [ 'error', 'all' ],
'default-case': 'error',
eqeqeq: [ 'error', 'always' ],
'for-direction': 'error',
'func-style': [ 'error', 'declaration' ],
'function-call-argument-newline': [ 'error', 'consistent' ],
'function-paren-newline': [ 'error', 'consistent' ],
'getter-return': [ 'error', { allowImplicit: true }],
'grouped-accessor-pairs': [ 'error', 'getBeforeSet' ],
'guard-for-in': 'error',
'line-comment-position': [ 'error', { position: 'above' }],
'linebreak-style': [ 'error', 'unix' ],
'multiline-comment-style': [ 'error', 'separate-lines' ],
// Need to override `allow` value
'no-console': [ 'error', { allow: [ '' ]}],
'no-constructor-return': 'error',
'no-dupe-else-if': 'error',
'no-else-return': [ 'error', { allowElseIf: false }],
'no-implicit-coercion': 'error',
'no-implicit-globals': 'error',
'no-lonely-if': 'error',
'no-plusplus': [ 'error', { allowForLoopAfterthoughts: true }],
'no-sync': [ 'error', { allowAtRootLevel: false }],
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'operator-assignment': [ 'error', 'always' ],
'prefer-object-spread': 'error',
radix: 'error',
'require-unicode-regexp': 'error',
'require-yield': 'error',
'sort-imports': [
'error',
{
allowSeparatedGroups: false,
ignoreCase: true,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: [ 'none', 'all', 'multiple', 'single' ],
},
],

'import/extensions': 'error',

'jsdoc/no-multi-asterisks': [ 'error', { allowWhitespace: true }],

'node/prefer-global/buffer': 'off',
'node/prefer-global/process': 'off',

'style/array-bracket-spacing': [ 'error', 'always', {
singleValue: true,
objectsInArrays: false,
arraysInArrays: false,
}],
// Conflicts with style/object-curly-spacing
'style/block-spacing': 'off',
'style/brace-style': [ 'error', '1tbs', { allowSingleLine: false }],
'style/generator-star-spacing': [ 'error', { before: false, after: true }],
// Seems to be inconsistent in when it adds indentation and when it does not
'style/indent-binary-ops': 'off',
'style/member-delimiter-style': [ 'error', {
multiline: { delimiter: 'semi', requireLast: true },
singleline: { delimiter: 'semi', requireLast: false },
}],
'style/no-extra-parens': [ 'error', 'functions' ],
'style/object-curly-spacing': [ 'error', 'always', {
objectsInObjects: false,
arraysInObjects: false,
}],
'style/operator-linebreak': [ 'error', 'after' ],
'style/semi': [ 'error', 'always' ],
'style/semi-style': [ 'error', 'last' ],
'style/space-before-function-paren': [ 'error', 'never' ],
'style/switch-colon-spacing': 'error',
'style/quote-props': [ 'error', 'as-needed', {
keywords: false,
unnecessary: true,
numbers: false,
}],
'style/yield-star-spacing': [ 'error', 'after' ],

'ts/adjacent-overload-signatures': 'error',
'ts/array-type': 'error',
'ts/ban-ts-comment': [ 'error', {
'ts-expect-error': true,
}],
'ts/consistent-indexed-object-style': [ 'error', 'record' ],
'ts/consistent-type-definitions': 'off',
'ts/explicit-member-accessibility': 'error',
'ts/method-signature-style': 'error',
'ts/no-confusing-non-null-assertion': 'error',
'ts/no-extraneous-class': [ 'error', {
allowConstructorOnly: false,
allowEmpty: false,
allowStaticOnly: false,
}],
'ts/no-inferrable-types': [ 'error', {
ignoreParameters: false,
ignoreProperties: false,
}],
'ts/prefer-for-of': 'error',
'ts/prefer-function-type': 'error',

'unused-imports/no-unused-vars': [
'error',
{ args: 'after-used', vars: 'all', ignoreRestSiblings: true },
],
},
};
53 changes: 53 additions & 0 deletions eslint/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const jest = require('eslint-plugin-jest');

// Specifically for tests
module.exports = {
// See https://github.com/jest-community/eslint-plugin-jest/issues/1408
plugins: {
jest,
},
files: [ '**/test/**/*.ts' ],
rules: {
...jest.configs.all.rules,
// Rule is not smart enough to check called function in the test
'jest/expect-expect': 'off',
'jest/valid-title': [ 'error', {
mustNotMatch: {
describe: /\.$/u.source,
},
mustMatch: {
it: /\.$/u.source,
},
}],

// Default rules that are overkill
'jest/no-hooks': 'off',
'jest/max-expects': 'off',
'jest/no-conditional-in-test': 'off',
'jest/prefer-expect-assertions': 'off',
'jest/prefer-lowercase-title': 'off',
'jest/prefer-strict-equal': 'off',
'jest/require-hook': 'off',

'test/prefer-lowercase-title': 'off',

'ts/naming-convention': 'off',
'ts/no-unsafe-argument': 'off',
'ts/no-unsafe-assignment': 'off',
'ts/no-unsafe-call': 'off',
'ts/no-unsafe-member-access': 'off',
'ts/no-unsafe-return': 'off',
'ts/unbound-method': 'off',

// Incorrectly detects usage of undefined in "toHaveBeenLastCalledWith" checks
'unicorn/no-useless-undefined': 'off',
'unicorn/filename-case': [ 'error', {
cases: {
camelCase: true,
pascalCase: false,
kebabCase: true,
snakeCase: false,
},
}],
},
};
Loading

0 comments on commit 2af1c24

Please sign in to comment.