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

ESLint fix #143

Merged
merged 1 commit into from
Sep 22, 2023
Merged
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
2,354 changes: 1,328 additions & 1,026 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"license": "MIT",
"devDependencies": {
"eslint": "^7.27.0",
"eslint-config-airbnb": "^17.1.0",
"eslint": "^8.49.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.23.3",
"jasmine": "^3.2.0",
"jasmine-expect": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const renderModel = require('../src/helpers/renderModel');

const renderModelFromRaw = (type) => {
const model = rawModels[type];
return renderModel(model, modelName => renderModelFromRaw(modelName));
return renderModel(model, (modelName) => renderModelFromRaw(modelName));
};

for (const type of Object.keys(rawModels)) {
Expand Down
14 changes: 7 additions & 7 deletions scripts/generateGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const generateGraph = (version, metaData, enums) => {
if (fieldPrefix === metaData.openActivePrefix) {
// Find an existing property
const found = propsAndClasses.rdfs_properties.filter(
value => value['@id'] === `${fieldPrefix}:${fieldSameAsName}`,
(value) => value['@id'] === `${fieldPrefix}:${fieldSameAsName}`,
);
let property;
if (found.length === 0) {
Expand Down Expand Up @@ -168,12 +168,12 @@ const generateGraph = (version, metaData, enums) => {
}
}
}
return Object.assign(
{},
metaData.baseGraph,
extraData,
propsAndClasses,
);
return {

...metaData.baseGraph,
...extraData,
...propsAndClasses,
};
};

module.exports = generateGraph;
4 changes: 2 additions & 2 deletions scripts/generatePropertyList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ const getPropertiesFromVocab = async (vocab) => {
'@type': 'rdf:Property',
'@explicit': true,
});
return framedOutput['@graph'].map(x => x['@id']);
return framedOutput['@graph'].map((x) => x['@id']);
};

const generatePropertyList = async graphs => (await Promise.all(graphs.map(getPropertiesFromVocab))).flat();
const generatePropertyList = async (graphs) => (await Promise.all(graphs.map(getPropertiesFromVocab))).flat();

module.exports = generatePropertyList;
4 changes: 2 additions & 2 deletions src/getExamplesWithContent-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ describe('getExamplesWithContent', () => {
});

it('should use remote fetcher for remote examples', async () => {
const mockFetcher = x => `Fetcher:${x}`;
const mockFetcher = (x) => `Fetcher:${x}`;

const examples = getExamplesWithContent('latest', mockFetcher);
expect(typeof examples).toBe('object');
expect(examples instanceof Array).toBe(true);

const remoteExamples = examples.filter(x => x.file.indexOf('http') === 0);
const remoteExamples = examples.filter((x) => x.file.indexOf('http') === 0);
expect(remoteExamples).toBeNonEmptyArray();

for (const { file, data } of remoteExamples) {
Expand Down
3 changes: 1 addition & 2 deletions src/getExamplesWithContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ const getExamples = require('./getExamples');
const EXAMPLES_DIRECTORY = `${__dirname}/../versions/2.x/examples/`;
const EXAMPLES_BASE_URL = 'https://openactive.io/data-models/versions/2.x/examples/';


const getExamplesWithContent = (version, fetcherForRemoteExamplesSync) => {
const examples = getExamples(version);
const flattenedExamples = examples.flatMap(x => x.exampleList.map(example => ({ category: x.name, ...example })));
const flattenedExamples = examples.flatMap((x) => x.exampleList.map((example) => ({ category: x.name, ...example })));
const output = [];
for (const example of flattenedExamples) {
if (example.file.indexOf('http') !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/getFullyQualifiedProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getFullyQualifiedProperty = (value, version, contexts = []) => {
if (contextsArg === null) {
contextsArg = [];
} else if (!(contextsArg instanceof Array)) {
contextsArg = [Object.assign({}, contextsArg)];
contextsArg = [{ ...contextsArg }];
} else {
contextsArg = contexts.slice();
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/loadModelMergeParent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const loadModelMergeParent = (paramModel, paramParentModel) => {
let model = Object.assign({}, paramModel);
let model = { ...paramModel };
const parentModel = paramParentModel;
for (const field in parentModel.fields) {
if (Object.prototype.hasOwnProperty.call(parentModel.fields, field)) {
Expand Down
2 changes: 1 addition & 1 deletion src/loadEnum.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const loadEnum = (name, version) => {
) {
throw Error(`Invalid enum name "${name}" supplied`);
}
return Object.assign({ name }, specs[specVersion].enums[name]);
return { name, ...specs[specVersion].enums[name] };
};

module.exports = loadEnum;
2 changes: 1 addition & 1 deletion src/loadModelFromFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const loadModelFromFile = (name, version) => {
}
const data = fs.readFileSync(jsonPath, 'utf8');
const model = JSON.parse(data);
return renderModel(model, modelName => loadModelFromFile(modelName, specVersion));
return renderModel(model, (modelName) => loadModelFromFile(modelName, specVersion));
};

module.exports = loadModelFromFile;
2 changes: 1 addition & 1 deletion src/mergeContexts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mergeContexts = (contexts = []) => {
if (contextsArg === null) {
contextsArg = [];
} else if (!(contextsArg instanceof Array)) {
contextsArg = [Object.assign({}, contextsArg)];
contextsArg = [{ ...contextsArg }];
} else {
contextsArg = contexts.slice();
}
Expand Down
8 changes: 4 additions & 4 deletions src/models-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const schemaOrgDataModel = (() => {
return entity['@id'].replace(/^schema:/, 'https://schema.org/');
};

return getSchemaOrgVocab()['@graph'].map(entity => getPrefixReplacedId(entity));
return getSchemaOrgVocab()['@graph'].map((entity) => getPrefixReplacedId(entity));
})();

const parseRDFXML = (uri) => {
Expand All @@ -38,7 +38,7 @@ const parseRDFXML = (uri) => {
$rdf.parse(rdf, store, uri, 'application/rdf+xml');

// Get all subjects specified in RDF file as a Set
const ids = new Set(store.statements.map(x => x.subject.value).filter(x => x.indexOf('n') !== 0));
const ids = new Set(store.statements.map((x) => x.subject.value).filter((x) => x.indexOf('n') !== 0));

// Return the Set
return ids;
Expand Down Expand Up @@ -568,7 +568,7 @@ describe('models', () => {
forEachField(jsonData, (field, fieldSpec) => {
if (typeof fieldSpec.description !== 'undefined') {
expect(fieldSpec.description instanceof Array
&& fieldSpec.description.filter(item => typeof item !== 'string').length === 0).toBe(true, field);
&& fieldSpec.description.filter((item) => typeof item !== 'string').length === 0).toBe(true, field);
} else if (field !== 'type') {
fail(`Does not have description, '${field}'.`);
}
Expand Down Expand Up @@ -668,7 +668,7 @@ describe('models', () => {
it('should have keys which are validationModes from the metadata', () => {
if (Object.prototype.hasOwnProperty.call(jsonData, 'validationMode')) {
const allowedValidationModes = metaData.validationModeGroups.reduce((allModes, group) => {
const modesInGroup = group.validationModeList.map(modeObj => modeObj.validationMode);
const modesInGroup = group.validationModeList.map((modeObj) => modeObj.validationMode);
return allModes.concat(modesInGroup);
}, []);
for (const validationMode of Object.keys(jsonData.validationMode)) {
Expand Down
Loading