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

Update meow dependency #41

Merged
merged 25 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3d46e64
refactor: update source to ES modules
ericcornelissen Oct 31, 2021
933cf72
chore(deps): update meow from ^3.7.0 to ^10.1.1
ericcornelissen Oct 31, 2021
9754f5a
chore(deps): add cosmiconfig to load configuration files
ericcornelissen Oct 31, 2021
d53539d
Merge branch 'master' into update-meow
ericcornelissen Nov 3, 2021
85a26d4
refactor: update tests to ES modules
ericcornelissen Nov 3, 2021
033d7db
fix: broken tests due to ESM mistakes in source
ericcornelissen Nov 3, 2021
dd3e2c5
Merge branch 'master' into update-meow
ericcornelissen Dec 3, 2021
7a8dc5e
chore: update ESLint and fix linting errors
ericcornelissen Dec 3, 2021
35a02af
chore: update package manifest for ESM only
ericcornelissen Dec 3, 2021
2349787
chore: unskip tests
ericcornelissen Dec 3, 2021
71b30f4
docs: update JS API example
ericcornelissen Dec 3, 2021
1e4eb07
fix: support ESM and CJS config files
ericcornelissen Dec 3, 2021
b63a829
refactor: simplify dynamic imports
ericcornelissen Dec 3, 2021
e8db954
docs: update config example to use ESM syntax
ericcornelissen Dec 3, 2021
31d582f
ci: run tests on Node v12, v14, and v16
ericcornelissen Dec 3, 2021
404fa2c
chore: adjust minimum v12 version to 12.17.0
ericcornelissen Dec 4, 2021
6c8d97f
ci: run tests on specific NodeJS versions rather then latest 12/14/16
ericcornelissen Dec 4, 2021
8db8147
revert: 404fa2c343e724a58864375e41420d52a0780bb7
ericcornelissen Dec 4, 2021
9783e5e
chore: make svglint config file an ESM
ericcornelissen Dec 12, 2021
83149e7
ci: update node-versions
ericcornelissen Dec 12, 2021
bf07134
chore: remove unnecessary semicolons
ericcornelissen Dec 12, 2021
6980c10
fix: loading config files and built-in rules on Windows
ericcornelissen Dec 14, 2021
b67761b
ci: run CLI on various node versions and operating systems
ericcornelissen Dec 14, 2021
f3e91a1
feat: add CJS version of Node API
ericcornelissen Dec 14, 2021
047242b
chore: add .npmrc to enforce `engine-strict` option
ericcornelissen Dec 15, 2021
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
4 changes: 4 additions & 0 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module.exports = {
"es6": true,
"jasmine": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020,
},
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 4, { "SwitchCase": 1 }],
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ jobs:
test:
name: Run tests
runs-on: ubuntu-18.04
strategy:
matrix:
node-version: [12, 14, 16]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -13,7 +16,7 @@ jobs:
- name: Node.js setup
uses: actions/setup-node@v1
ericcornelissen marked this conversation as resolved.
Show resolved Hide resolved
with:
node-version: 12
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Lint
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ $ svglint --help
The tool can also be used through the JS API.

```javascript
const SVGLint = require("svglint");
const linting = SVGLint.lintSource("<svg>...</svg>", {
import SVGLint from "svglint";

const linting = await SVGLint.lintSource("<svg>...</svg>", {
// ... config goes here
});
linting.on("done", () => {
Expand All @@ -50,7 +51,7 @@ If you are using the CLI, this configuration object is read from the file specif
This configuration file should export a single object, of the format:

```javascript
module.exports = {
export default {
// additional configuration may go here in the future
// for now, "rules" is the only useful key
rules: {
Expand All @@ -66,7 +67,7 @@ module.exports = {
function() { // config 1 for the "custom" rule }
]
}
};
}
```

For specifics on how the config for each rule should be formatted, see [their specific rule files](https://github.com/birjolaxew/svglint/tree/master/src/rules).
Expand Down
31 changes: 16 additions & 15 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
* @fileoverview The CLI that is executed from a terminal.
* Acts as an interface to the JS API
*/
const path = require("path");
const GUI = new (require("../src/cli/gui"));
const Logger = require("../src/lib/logger");
const SVGLint = require("../src/svglint");
import path from "path";
import gui from "../src/cli/gui.js";
import Logger from "../src/lib/logger.js";
import SVGLint from "../src/svglint.js";
// @ts-ignore
const meta = require("../package.json");
const { getConfigurationFile } = require("../src/cli/config");
const meow = require("meow");
const chalk = require("chalk");
const glob = require("glob");
import config from "../src/cli/config.js";
import meow from "meow";
import chalk from "chalk";
import glob from "glob";

const GUI = new gui();
const { getConfigurationFile } = config;

const logger = Logger("");
// Pretty logs all errors, then exits
Expand All @@ -23,10 +25,7 @@ process.on("uncaughtException", err => {
});

// Generates the CLI binding using meow
const cli = meow({
description: meta.description,
version: meta.version,
help: `
const cli = meow(`
${chalk.yellow("Usage:")}
${chalk.bold("svglint")} [--config config.js] [--ci] [--debug] ${chalk.bold("file1.svg file2.svg")}

Expand All @@ -35,7 +34,8 @@ const cli = meow({
${chalk.bold("--version")} Show the current SVGLint version
${chalk.bold("--config, -c")} Specify the config file. Defaults to '.svglintrc.js'
${chalk.bold("--debug, -d")} Show debug logs
${chalk.bold("--ci, -C")} Only output to stdout once, when linting is finished`,
${chalk.bold("--ci, -C")} Only output to stdout once, when linting is finished`, {
importMeta: import.meta,
flags: {
config: { type: "string", alias: "c", },
debug: { type: "boolean", alias: "d" },
Expand All @@ -62,7 +62,8 @@ process.on("exit", () => {
try {
const configFile = await getConfigurationFile(cli.flags.config);
if (configFile) {
configObj = require(configFile);
const module = await import(configFile);
configObj = module.default;
} else {
logger.debug("No configuration file found")
if (cli.flags.config) {
Expand Down
Loading