Skip to content

Commit

Permalink
Drop to support Node.js 10.x (#773)
Browse files Browse the repository at this point in the history
* CI: drop support Node.js 10.x

* fix(textlint): update engines field for ESM

* style: apply prettier

* CI: support Node.js 16

* chore: fix type

* chore: remove .js

* chore: omit allowJs

* chore: omit allowJs

* fix

* refactor: remove "rootDir" in tsconfig.json

avoid "ts-node Emit skipped allowjs" error TypeStrong/ts-node#693

* chore: rm debug

* fix test

* fix test

* fix test

* fix test

* fix bin

* update

* fix: example
  • Loading branch information
azu committed May 22, 2021
1 parent 1c98981 commit fea2cf3
Show file tree
Hide file tree
Showing 84 changed files with 1,772 additions and 1,911 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
@@ -1,3 +1,5 @@
lib/
out/
module/
node_modules/
test/integration-test/
2 changes: 2 additions & 0 deletions .githooks/pre-commit
@@ -0,0 +1,2 @@
#!/bin/sh
npx --no-install lint-staged
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [ 10, 12, 14 ]
node: [ 12, 14 , 16]
include:
- node: 14
os: macos-latest
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Expand Up @@ -2,3 +2,4 @@ out/
lib/
module/
node_modules/
test/integration-test/
4 changes: 2 additions & 2 deletions docs/example/rules/example-rule.js
Expand Up @@ -3,10 +3,10 @@
/**
* @param {RuleContext} context
*/
module.exports = function(context) {
module.exports = function (context) {
var exports = {};
var limitLength = 80;
exports[context.Syntax.Str] = function(node) {
exports[context.Syntax.Str] = function (node) {
var text = context.getSource(node);
if (text.length > limitLength) {
context.report(node, new context.RuleError("This paragraph is long : \n" + text));
Expand Down
6 changes: 3 additions & 3 deletions examples/perf/perf.js
Expand Up @@ -21,7 +21,7 @@ var PERF_MULTIPLIER = 7.5e6;
*/
function time(cmd, runs, runNumber, results, cb) {
var start = process.hrtime();
exec(cmd, { silent: true }, function() {
exec(cmd, { silent: true }, function () {
var diff = process.hrtime(start),
actual = diff[0] * 1e3 + diff[1] / 1e6; // ms

Expand All @@ -41,8 +41,8 @@ function run() {
var TEXTLINT = "node " + __dirname + "/node_modules/.bin/textlint";
var target = __dirname + "/md/";
var cmd = TEXTLINT + " " + target;
time(cmd, 5, 1, [], function(results) {
results.sort(function(a, b) {
time(cmd, 5, 1, [], function (results) {
results.sort(function (a, b) {
return a - b;
});

Expand Down
7 changes: 3 additions & 4 deletions examples/perf/run.js
Expand Up @@ -2,11 +2,10 @@
"use strict";
// run as app
var cli = require("textlint").cli;
cli
.execute(process.argv.concat(__dirname + "/md/"))
.then(function(exit) {
cli.execute(process.argv.concat(__dirname + "/md/"))
.then(function (exit) {
console.log(exit);
})
.catch(function(error) {
.catch(function (error) {
console.error(error);
});
12 changes: 6 additions & 6 deletions examples/rulesdir/rules/no-todo.js
Expand Up @@ -24,19 +24,19 @@ function getParents(node) {
*/
function isNodeWrapped(node, types) {
var parents = getParents(node);
var parentsTypes = parents.map(function(parent) {
var parentsTypes = parents.map(function (parent) {
return parent.type;
});
return types.some(function(type) {
return parentsTypes.some(function(parentType) {
return types.some(function (type) {
return parentsTypes.some(function (parentType) {
return parentType === type;
});
});
}
/**
* @param {RuleContext} context
*/
module.exports = function(context) {
module.exports = function (context) {
var exports = {};
// When `Node`'s type is `Str` come, call this callback.
/*
Expand All @@ -49,7 +49,7 @@ module.exports = function(context) {
*/
// "This is Str." and "Todo: quick fix this." are `Str` type.
// This callback function is called twice.
exports[context.Syntax.Str] = function(node) {
exports[context.Syntax.Str] = function (node) {
var Syntax = context.Syntax;
if (isNodeWrapped(node, [Syntax.Link, Syntax.Image, Syntax.BlockQuote])) {
return;
Expand All @@ -70,7 +70,7 @@ module.exports = function(context) {
- [ ] todo
*/
// `List` is "- list 1" and - [ ] todo", so called this callback twice.
exports[context.Syntax.ListItem] = function(node) {
exports[context.Syntax.ListItem] = function (node) {
var text = context.getSource(node);
if (/\[\s+\]\s/i.test(text)) {
context.report(node, new context.RuleError("found TODO: '" + text + "'"));
Expand Down
4 changes: 2 additions & 2 deletions examples/use-as-module/index.js
Expand Up @@ -13,7 +13,7 @@ function lintFile(filePath) {
};
var engine = new TextLintEngine(options);
var filePathList = [path.resolve(process.cwd(), filePath)];
return engine.executeOnFiles(filePathList).then(function(results) {
return engine.executeOnFiles(filePathList).then(function (results) {
if (engine.isErrorResults(results)) {
var output = engine.formatResults(results);
console.log(output);
Expand All @@ -23,7 +23,7 @@ function lintFile(filePath) {
});
}

lintFile(__dirname + "/README.md").catch(function(error) {
lintFile(__dirname + "/README.md").catch(function (error) {
console.error(error);
process.exit(1);
});
8 changes: 4 additions & 4 deletions examples/use-as-ts-module/package.json
Expand Up @@ -4,13 +4,13 @@
"private": true,
"license": "MIT",
"author": "0x6b",
"main": "lib/index.js",
"main": "lib/src/index.js",
"scripts": {
"prebuild": "npm-run-all clean",
"build": "tsc -b",
"clean": "rimraf lib/ module/ tsconfig.tsbuildinfo tsconfig.module.tsbuildinfo",
"clean": "rimraf lib/ module/",
"pretest": "npm-run-all build",
"test": "node lib/index.js fixtures/success.md",
"test": "node lib/src/index.js fixtures/success.md",
"test:ci": "npm test"
},
"dependencies": {
Expand All @@ -23,7 +23,7 @@
"cross-env": "^7.0.2",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"typescript": "~4.0.2"
"typescript": "~4.2.4"
},
"files": [
"bin/",
Expand Down
10 changes: 5 additions & 5 deletions examples/use-as-ts-module/src/index.ts
@@ -1,11 +1,11 @@
// LICENSE : MIT
"use strict";
import {argv, cwd, exit} from "process";
import {resolve} from "path";
import {TextLintEngine} from "textlint";
import {TextlintResult} from "@textlint/kernel";
import { argv, cwd, exit } from "process";
import { resolve } from "path";
import { TextLintEngine } from "textlint";
import { TextlintResult } from "@textlint/kernel";

const [, , filename] = argv
const [, , filename] = argv;

function lintFile(filePath: string) {
const filePathList = [resolve(cwd(), filePath)];
Expand Down
1 change: 0 additions & 1 deletion examples/use-as-ts-module/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"references": [
Expand Down
13 changes: 7 additions & 6 deletions package.json
Expand Up @@ -28,8 +28,9 @@
"test:packages": "lerna run test --ignore integration-test --ignore textlint-example-* --ignore textlint-script-* --ignore textlint-website",
"test:projectReferences": "workspaces-to-typescript-project-references --check",
"update:projectReferences": "workspaces-to-typescript-project-references",
"prettier": "prettier --write \"packages/**/*.{js,jsx,ts,tsx,css}\"",
"yarn-check": "yarn check --integrity || (echo '=> Please run `$ yarn bootstrap`' && exit 1)"
"yarn-check": "yarn check --integrity || (echo '=> Please run `$ yarn bootstrap`' && exit 1)",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
"prepare": "git config --local core.hooksPath .githooks"
},
"devDependencies": {
"@azu/travis-scripts": "^3.0.3",
Expand All @@ -40,18 +41,18 @@
"eslint": "^7.9.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^4.3.8",
"lerna": "^3.22.1",
"lint-staged": "^10.5.4",
"lerna": "^4.0.0",
"lint-staged": "^11.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1"
"prettier": "^2.3.0"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,css}": [
"prettier --write"
]
},
"prettier": {
"singleQuote": false,
"printWidth": 120,
"tabWidth": 4,
"trailingComma": "none"
Expand Down
10 changes: 5 additions & 5 deletions packages/@textlint/ast-node-types/package.json
Expand Up @@ -11,9 +11,9 @@
},
"license": "MIT",
"author": "azu",
"main": "./lib/index.js",
"module": "./module/index.js",
"types": "./lib/index.d.ts",
"main": "./lib/src/index.js",
"module": "./module/src/index.js",
"types": "./lib/src/index.d.ts",
"files": [
"bin/",
"lib/",
Expand All @@ -22,7 +22,7 @@
],
"scripts": {
"build": "tsc -b && tsc -b tsconfig.module.json",
"clean": "rimraf lib/ module/ tsconfig.tsbuildinfo tsconfig.module.tsbuildinfo",
"clean": "rimraf lib/ module/",
"prepublish": "npm run build",
"test": "mocha \"test/**/*.{js,ts}\""
},
Expand All @@ -32,6 +32,6 @@
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"ts-node-test-register": "^9.0.1",
"typescript": "~4.0.2"
"typescript": "~4.2.4"
}
}
1 change: 0 additions & 1 deletion packages/@textlint/ast-node-types/test/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"composite": false,
"noEmit": true
},
Expand Down
1 change: 0 additions & 1 deletion packages/@textlint/ast-node-types/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
Expand Down
10 changes: 5 additions & 5 deletions packages/@textlint/ast-tester/package.json
Expand Up @@ -19,9 +19,9 @@
},
"license": "MIT",
"author": "azu",
"main": "lib/index.js",
"module": "./module/index.js",
"types": "lib/index.d.ts",
"main": "lib/src/index.js",
"module": "./module/src/index.js",
"types": "lib/src/index.d.ts",
"directories": {
"test": "test"
},
Expand All @@ -33,7 +33,7 @@
],
"scripts": {
"build": "tsc -b && tsc -b tsconfig.module.json",
"clean": "rimraf lib/ module/ tsconfig.tsbuildinfo tsconfig.module.tsbuildinfo",
"clean": "rimraf lib/ module/",
"prepublish": "npm run --if-present build",
"test": "mocha \"test/**/*.{js,ts}\"",
"watch": "tsc -b --watch"
Expand All @@ -49,7 +49,7 @@
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"ts-node-test-register": "^9.0.1",
"typescript": "^4.0.2"
"typescript": "^4.2.4"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion packages/@textlint/ast-tester/test/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"composite": false,
"noEmit": true
},
Expand Down
1 change: 0 additions & 1 deletion packages/@textlint/ast-tester/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
Expand Down
10 changes: 5 additions & 5 deletions packages/@textlint/ast-traverse/package.json
Expand Up @@ -16,9 +16,9 @@
},
"license": "MIT",
"author": "azu",
"main": "./lib/index.js",
"module": "./module/index.js",
"types": "./lib/index.d.ts",
"main": "./lib/src/index.js",
"module": "./module/src/index.js",
"types": "./lib/src/index.d.ts",
"directories": {
"test": "test/"
},
Expand All @@ -30,7 +30,7 @@
],
"scripts": {
"build": "tsc -b && tsc -b tsconfig.module.json",
"clean": "rimraf lib/ module/ tsconfig.tsbuildinfo tsconfig.module.tsbuildinfo",
"clean": "rimraf lib/ module/",
"prepublish": "npm run --if-present build",
"test": "mocha \"test/**/*.ts\"",
"watch": "tsc -b --watch"
Expand All @@ -47,7 +47,7 @@
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"ts-node-test-register": "^9.0.1",
"typescript": "~4.0.2"
"typescript": "~4.2.4"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion packages/@textlint/ast-traverse/test/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"composite": false,
"noEmit": true
},
Expand Down
1 change: 0 additions & 1 deletion packages/@textlint/ast-traverse/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
Expand Down
10 changes: 5 additions & 5 deletions packages/@textlint/feature-flag/package.json
Expand Up @@ -15,9 +15,9 @@
},
"license": "MIT",
"author": "azu",
"type": "lib/index.d.ts",
"main": "lib/index.js",
"module": "./module/index.js",
"main": "./lib/src/index.js",
"types": "./lib/src/index.d.ts",
"module": "./module/src/index.js",
"directories": {
"test": "test"
},
Expand All @@ -29,7 +29,7 @@
],
"scripts": {
"build": "tsc -b && tsc -b tsconfig.module.json",
"clean": "rimraf lib/ module/ tsconfig.tsbuildinfo tsconfig.module.tsbuildinfo",
"clean": "rimraf lib/ module/",
"prepublish": "npm run --if-present build",
"test": "mocha \"test/**/*.ts\"",
"watch": "tsc -b --watch"
Expand All @@ -45,6 +45,6 @@
"rimraf": "^3.0.2",
"ts-node": "^9.1.1",
"ts-node-test-register": "^9.0.1",
"typescript": "^4.0.2"
"typescript": "^4.2.4"
}
}
1 change: 0 additions & 1 deletion packages/@textlint/feature-flag/test/tsconfig.json
@@ -1,7 +1,6 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"composite": false,
"noEmit": true
},
Expand Down

0 comments on commit fea2cf3

Please sign in to comment.