Skip to content

Commit

Permalink
Sync eslint config with base comunica
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Mar 20, 2024
1 parent d3e8018 commit 588e946
Show file tree
Hide file tree
Showing 20 changed files with 1,885 additions and 427 deletions.
35 changes: 0 additions & 35 deletions .eslintrc.js

This file was deleted.

18 changes: 9 additions & 9 deletions engines/config-query-sparql-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
"version": "3.0.0",
"description": "default configuration files for Comunica SPARQL Solid",
"lsd:module": true,
"main": "lib/index.js",
"typings": "lib/index",
"license": "MIT",
"homepage": "https://comunica.dev/",
"repository": {
"type": "git",
"url": "https://github.com/comunica/comunica-feature-solid.git",
"directory": "engines/config-query-sparql-solid"
},
"publishConfig": {
"access": "public"
"bugs": {
"url": "https://github.com/comunica/comunica-feature-solid/issues"
},
"sideEffects": false,
"keywords": [
"comunica",
"sparql",
Expand All @@ -23,11 +22,12 @@
"config",
"solid"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/comunica/comunica-feature-solid/issues"
"sideEffects": false,
"main": "lib/index.js",
"typings": "lib/index",
"publishConfig": {
"access": "public"
},
"homepage": "https://comunica.dev/",
"files": [
"components",
"config",
Expand Down
2 changes: 1 addition & 1 deletion engines/query-sparql-solid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This library has the following known issues in certain cases, that are out of ou
* **Web Workers**: This library can not be used within due to an open issue in https://github.com/inrupt/solid-client-authn-js/issues/1657
* **Enterprise Solid Server** (https://pod.inrupt.com/):
* Patch requests are not accepted, so only new documents can be created, but existing ones can not be modified.
* Due to missing `Accept-Patch`, and `Accept-Put` headers, [the destination type has to be forced](https://comunica.dev/docs/query/advanced/destination_types/). This will only work for creating new documents via the `putLdp` destination type. Updating existing documents via `patchSparqlUpdate` are currently not possible because of the previous issue.
* Due to missing `Accept-Patch`, and `Accept-Put` headers, [the destination type has to be forced](https://comunica.dev/docs/query/advanced/destination_types/). This will only work for creating new documents via the `putLdp` destination type. Updating existing documents via `patchSparqlUpdate` are currently not possible because of the previous issue.
* **Node Solid Server** (https://solidcommunity.net/):
* Querying or updating existing documents fails with the error `Error translating between RDF formats` (https://github.com/solid/node-solid-server/issues/1618). Creating new documents does work.

Expand Down
3 changes: 2 additions & 1 deletion engines/query-sparql-solid/bin/http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
/* eslint-disable node/no-path-concat */
import { HttpServiceSparqlEndpoint } from '@comunica/actor-init-query';
import { CliArgsHandlerSolidAuth } from '../lib/CliArgsHandlerSolidAuth';

Expand All @@ -11,7 +12,7 @@ HttpServiceSparqlEndpoint.runArgsInProcess(
`${__dirname}/../`,
process.env,
defaultConfigPath,
code => {
(code) => {
process.exit(code);
},
[ new CliArgsHandlerSolidAuth() ],
Expand Down
1 change: 1 addition & 0 deletions engines/query-sparql-solid/bin/query-dynamic.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env node
/* eslint-disable node/no-path-concat */
import { KeysInitQuery } from '@comunica/context-entries';
import { ActionContext } from '@comunica/core';
import { runArgsInProcess } from '@comunica/runner-cli';
Expand Down
3 changes: 2 additions & 1 deletion engines/query-sparql-solid/bin/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { runArgsInProcessStatic } from '@comunica/runner-cli';
import { CliArgsHandlerSolidAuth } from '../lib/CliArgsHandlerSolidAuth';

const cliArgsHandlerSolidAuth = new CliArgsHandlerSolidAuth();
runArgsInProcessStatic(require('../engine-default.js'), {
// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions
runArgsInProcessStatic(require('../engine-default.js')(), {
context: new ActionContext({
[KeysInitQuery.cliArgsHandlers.name]: [ cliArgsHandlerSolidAuth ],
}),
Expand Down
1 change: 1 addition & 0 deletions engines/query-sparql-solid/lib/CliArgsHandlerSolidAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ICliArgsHandler } from '@comunica/types';
import type { Session } from '@rubensworks/solid-client-authn-isomorphic';
import type { Argv } from 'yargs';

// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires
const { interactiveLogin } = require('solid-node-interactive-auth');

/**
Expand Down
3 changes: 2 additions & 1 deletion engines/query-sparql-solid/lib/QueryEngine.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { QueryEngineBase } from '@comunica/actor-init-query';
import type { ActorInitQueryBase } from '@comunica/actor-init-query';

// eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions
const engineDefault = require('../engine-default.js');

/**
* A Comunica SPARQL query engine.
*/
export class QueryEngine extends QueryEngineBase {
public constructor(engine: ActorInitQueryBase = engineDefault) {
public constructor(engine: ActorInitQueryBase = engineDefault()) {
super(engine);
}
}
1 change: 1 addition & 0 deletions engines/query-sparql-solid/lib/QueryEngineFactory.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable node/no-path-concat */
import { QueryEngineFactoryBase } from '@comunica/actor-init-query';
import { QueryEngine } from './QueryEngine';

Expand Down
40 changes: 20 additions & 20 deletions engines/query-sparql-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
"version": "3.0.0",
"description": "A Comunica engine for query evaluation over Solid data pods",
"lsd:module": true,
"main": "lib/index.js",
"typings": "lib/index",
"license": "MIT",
"homepage": "https://comunica.dev/",
"repository": "https://github.com/comunica/comunica-feature-solid/tree/master/engines/query-sparql-solid",
"publishConfig": {
"access": "public"
"bugs": {
"url": "https://github.com/comunica/comunica/issues"
},
"sideEffects": false,
"keywords": [
"comunica",
"sparql",
Expand All @@ -22,27 +21,34 @@
"sparql 1.1",
"solid"
],
"license": "MIT",
"sideEffects": false,
"main": "lib/index.js",
"typings": "lib/index",
"publishConfig": {
"access": "public"
},
"bin": {
"comunica-sparql-solid": "bin/query.js",
"comunica-sparql-solid-http": "bin/http.js",
"comunica-dynamic-sparql-solid": "bin/query-dynamic.js"
},
"bugs": {
"url": "https://github.com/comunica/comunica/issues"
},
"homepage": "https://comunica.dev/",
"files": [
"components",
"config",
"bin/**/*.d.ts",
"bin/**/*.js",
"bin/**/*.js.map",
"components",
"config",
"engine-default.js",
"lib/**/*.d.ts",
"lib/**/*.js",
"lib/**/*.js.map",
"engine-default.js"
"lib/**/*.js.map"
],
"scripts": {
"build": "npm run build:ts",
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
"prepare": "comunica-compile-config config/config-default.json > engine-default.js",
"browser": "npm run prepare && \"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --mode production"
},
"dependencies": {
"@comunica/actor-context-preprocess-convert-shortcuts": "^3.0.1",
"@comunica/actor-context-preprocess-query-source-identify": "^3.0.1",
Expand Down Expand Up @@ -192,12 +198,6 @@
"@rubensworks/solid-client-authn-isomorphic": "^2.0.0",
"solid-node-interactive-auth": "^1.0.2"
},
"scripts": {
"build": "npm run build:ts",
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
"prepare": "comunica-compile-config config/config-default.json > engine-default.js",
"browser": "npm run prepare && \"../../node_modules/webpack/bin/webpack.js\" --config webpack.config.js --mode production"
},
"browser": {
"./lib/index.js": "./lib/index-browser.js"
}
Expand Down
12 changes: 6 additions & 6 deletions engines/query-sparql-solid/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copied from: https://github.com/comunica/comunica/blob/master/packages/actor-init-sparql/webpack.config.js
const path = require('path');
const path = require('node:path');
const ProgressPlugin = require('webpack').ProgressPlugin;

module.exports = {
Expand All @@ -8,19 +8,19 @@ module.exports = {
filename: 'comunica-browser.js',
path: __dirname,
libraryTarget: 'var',
library: 'Comunica'
library: 'Comunica',
},
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
test: /\.js$/u,
loader: 'babel-loader',
exclude: /node_modules/,
exclude: /node_modules/u,
},
]
],
},
plugins: [
new ProgressPlugin(),
]
],
};
95 changes: 95 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
const config = require('@rubensworks/eslint-config');

module.exports = config([
{
files: [ '**/*.ts' ],
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname,
project: [ './tsconfig.eslint.json' ],
},
},
},
{
rules: {
// Default
'unicorn/consistent-destructuring': 'off',
'unicorn/no-array-callback-reference': 'off',

// TODO: check if these can be enabled
'ts/naming-convention': 'off',
'ts/no-unsafe-return': 'off',
'ts/no-unsafe-argument': 'off',
'ts/no-unsafe-assignment': 'off',

'ts/no-require-imports': [ 'error', { allow: [
'process/',
'web-streams-ponyfill',
'is-stream',
'readable-stream-node-to-web',
'stream-to-string',
]}],
'ts/no-var-requires': [ 'error', { allow: [
'process/',
'web-streams-ponyfill',
'is-stream',
'readable-stream-node-to-web',
'stream-to-string',
]}],
},
},
{
// Specific rules for NodeJS-specific files
files: [
'**/test/**/*.ts',
],
rules: {
'import/no-nodejs-modules': 'off',
'unused-imports/no-unused-vars': 'off',
'ts/no-require-imports': 'off',
'ts/no-var-requires': 'off',
},
},
{
// The config packages use an empty index.ts
files: [
'engines/config-*/lib/index.ts',
],
rules: {
'import/unambiguous': 'off',
},
},
{
// Some test files import 'jest-rdf' which triggers this
// The http actors import 'cross-fetch/polyfill' which also triggers this
// Some jest tests import '../../lib' which triggers this
files: [
'**/test/*-test.ts',
'**/test/*-util.ts',
],
rules: {
'import/no-unassigned-import': 'off',
},
},
{
// Files that do not require linting
ignores: [
'setup-jest.js',
'**/engine-default.js',
'**/engine-browser.js',
'**/comunica-browser.js',
'.github/**',
'**/bintest/**',
],
},
{
files: [ '**/*.js' ],
rules: {
'ts/no-require-imports': 'off',
'ts/no-var-requires': 'off',
'import/no-nodejs-modules': 'off',
'import/no-extraneous-dependencies': 'off',
'import/extensions': 'off',
},
},
]);
14 changes: 7 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
module.exports = {
transform: {
'^.+\\.ts$': 'ts-jest'
'^.+\\.ts$': 'ts-jest',
},
testRegex: '/test/.*-test.ts$',
moduleFileExtensions: [
'ts',
'js'
'js',
],
globals: {
'ts-jest': {
isolatedModules: true
isolatedModules: true,
},
},
setupFilesAfterEnv: [ './setup-jest.js' ],
collectCoverage: true,
coveragePathIgnorePatterns: [
'/node_modules/',
'/mocks/',
'index.js'
'index.js',
],
testEnvironment: 'node',
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100
}
}
statements: 100,
},
},
};
Loading

0 comments on commit 588e946

Please sign in to comment.