mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-04-18 16:09:15 +00:00
Merge pull request #78 from tatianamac/feature/eslint-ava
🏡 Install ESLint && Ava
This commit is contained in:
commit
b78dd4a334
11
.eleventy.js
11
.eleventy.js
@ -1,16 +1,15 @@
|
||||
const makeItemLink = (slug) => `#${slug}`;
|
||||
const findExistingDefinition = (word, collection) =>
|
||||
collection.find((item) => item.data.title === word);
|
||||
const findExistingDefinition = require('./11ty/filters/helpers/findExistingDefinition');
|
||||
const definitionPermalink = require('./11ty/filters/definitionPermalink');
|
||||
|
||||
module.exports = function(config) {
|
||||
// Add a filter using the Config API
|
||||
config.addFilter('linkTarget', makeItemLink);
|
||||
config.addFilter('linkTarget', definitionPermalink);
|
||||
|
||||
config.addFilter('linkIfExistsInCollection', (word, collection) => {
|
||||
const existingDefinition = findExistingDefinition(word, collection);
|
||||
|
||||
if (existingDefinition) {
|
||||
return `<a href="${makeItemLink(
|
||||
return `<a href="${definitionPermalink(
|
||||
existingDefinition.data.slug
|
||||
)}">${word}</a>`;
|
||||
}
|
||||
@ -25,7 +24,7 @@ module.exports = function(config) {
|
||||
);
|
||||
|
||||
if (existingDefinition) {
|
||||
return `<a href="${makeItemLink(
|
||||
return `<a href="${definitionPermalink(
|
||||
existingDefinition.data.slug
|
||||
)}" aria-label="${subTermData.full_title}">${subTermData.text}</a>`;
|
||||
}
|
||||
|
12
.eslintrc.json
Normal file
12
.eslintrc.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
|
||||
"ignorePatterns": ["node_modules/"],
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2020": true,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
7
11ty/filters/_tests/definitionPermalink.spec.js
Normal file
7
11ty/filters/_tests/definitionPermalink.spec.js
Normal file
@ -0,0 +1,7 @@
|
||||
import test from 'ava';
|
||||
|
||||
import definitionPermalink from '../definitionPermalink';
|
||||
|
||||
test('constructs correct detail link', (t) => {
|
||||
t.is(definitionPermalink('test-slug'), '/#test-slug');
|
||||
});
|
3
11ty/filters/definitionPermalink.js
Normal file
3
11ty/filters/definitionPermalink.js
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function(slug) {
|
||||
return `/#${slug}`;
|
||||
};
|
2
11ty/filters/helpers/findExistingDefinition.js
Normal file
2
11ty/filters/helpers/findExistingDefinition.js
Normal file
@ -0,0 +1,2 @@
|
||||
module.exports = (word, collection) =>
|
||||
collection.find((item) => item.data.title === word);
|
5
ava.config.js
Normal file
5
ava.config.js
Normal file
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
files: ['./**/*.spec.js'],
|
||||
require: ['esm'],
|
||||
verbose: true
|
||||
};
|
2598
package-lock.json
generated
2598
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -5,15 +5,17 @@
|
||||
"description": "A modern dictionary about us.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "npm run build:css && npm run build:site",
|
||||
"build:site": "eleventy",
|
||||
"build:css": "parcel build assets/css/base.scss --out-dir dist/assets/css/",
|
||||
"watch": "eleventy --watch",
|
||||
"build:site": "eleventy",
|
||||
"build": "npm run build:css && npm run build:site",
|
||||
"create-definitions": "bin/create-definitions",
|
||||
"lint": "npm run lint:js",
|
||||
"lint:js": "eslint \"11ty/**/*.js\"",
|
||||
"serve": "concurrently \"npm run serve:site\" \"npm run watch:css\"",
|
||||
"watch:css": "parcel watch assets/css/base.scss --out-dir dist/assets/css/",
|
||||
"serve:site": "eleventy --serve",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"create-definitions": "bin/create-definitions"
|
||||
"test": "ava",
|
||||
"watch": "eleventy --watch",
|
||||
"watch:css": "parcel watch assets/css/base.scss --out-dir dist/assets/css/"
|
||||
},
|
||||
"bin": {
|
||||
"create-definitions": "bin/create-definitions"
|
||||
@ -38,9 +40,14 @@
|
||||
"prism-themes": "^1.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.3.0",
|
||||
"concurrently": "^5.0.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"esm": "^3.2.25",
|
||||
"parcel-bundler": "^1.12.4",
|
||||
"prettier": "^1.19.1",
|
||||
"sass": "^1.23.7",
|
||||
"slugify": "^1.3.6"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user